rewrite protocol check with switch-case in daemon

ping @crosbymichael @shykes @vieux

Please review. Thanks.