{"action":"created","comment":{"url":"https://api.github.com/repos/TheBlueMatt/mining-proxy/pulls/comments/202506192","pull_request_review_id":137229052,"id":202506192,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIwMjUwNjE5Mg==","diff_hunk":"@@ -0,0 +1,89 @@\n+// We will need a simple redis command for authentication now.\n+// Set \"BetterHash:AuthorizedUsers\" should be created in redis database, and fill with \n+// authorized users. We use `sismember` command to check if connected user is authorized.\n+\n+extern crate simple_redis;\n+\n+use std::sync::Mutex;\n+\n+// Redis set which includes all valid miner usernames.\n+const REDIS_AUTHORIZED_USERS_KEY: &'static str = \"BetterHash:AuthorizedUsers\";\n+\n+pub struct RedisAuthenticatorSettings {\n+\tredis_url: Option<String>\n+}\n+\n+pub struct RedisAuthenticatorState {\n+\tclient: Mutex<simple_redis::client::Client>,\n+\tusers_key: String,\n+}\n+\n+pub fn init_authenticator_settings() -> RedisAuthenticatorSettings {\n+\tRedisAuthenticatorSettings {\n+\t\tredis_url: None,\n+\t}\n+}\n+\n+pub fn print_authenticator_parameters() {\n+\tprintln!(\"--redis_url - Redis url: redis://host:port/\");\n+}\n+\n+/// Returns true if the given parameter could be parsed into a setting this Authenticator understands\n+pub fn parse_authenticator_parameter(settings: &mut RedisAuthenticatorSettings, arg: &str) -> bool {\n+\tif arg.starts_with(\"--redis_url\") {\n+\t\tif settings.redis_url.is_some() {\n+\t\t\tprintln!(\"Cannot specify multiple redis_urls\");\n+\t\t\tfalse\n+\t\t} else {\n+\t\t\tlet redis_url = arg.split_at(12).1;\n+\t\t\tif !redis_url.starts_with(\"redis://\") {\n+\t\t\t\tprintln!(\"Please provide a valid redis url: redis://host:ip/\");\n+\t\t\t\tpanic!();\n+\t\t\t}\n+\t\t\tsettings.redis_url = Some(redis_url.to_string());\n+\t\t\ttrue\n+\t\t}\n+\t} else {\n+\t\tfalse\n+\t}\n+}\n+\n+pub fn setup_authenticator(settings: RedisAuthenticatorSettings) -> RedisAuthenticatorState {\n+\tif settings.redis_url.is_none() {\n+\t\tprintln!(\"Need redis url, build with a generic Authenticator if you want to just get prints\");\n+\t\tpanic!();\n+\t}\n+\n+    // Redis connection resiliency will be handled by simple-redis\n+\tlet client = match simple_redis::create(&settings.redis_url.unwrap()) {\n+\t\tOk(client) => client,\n+\t\tErr(e) => {\n+\t\t\tpanic!(\"Failed to connect to redis: {:?}\", e);\n+\t\t},\n+\t};\n+\n+\tRedisAuthenticatorState {\n+\t\tclient: Mutex::new(client),\n+\t\tusers_key: REDIS_AUTHORIZED_USERS_KEY.to_string(),\n+\t}\t\n+}\n+\n+/// Returns true if the given user_id/auth pair is valid for this pool. Note that the pool_proxy\n+/// stuff doesn't really bother with auth, so if you use it you probably can't reliably check\n+/// user_auth, but there probably isnt any reason to ever anyway...\n+pub fn check_user_auth(state: &RedisAuthenticatorState, user_id: &Vec<u8>, _user_auth: &Vec<u8>) -> bool {\n+\tlet user_id_string = String::from_utf8_lossy(user_id);","path":"src/redis_authenticator.rs","position":75,"original_position":75,"commit_id":"63061085b8ce03444ff0d7dddcd0e31ddfebbeef","original_commit_id":"63061085b8ce03444ff0d7dddcd0e31ddfebbeef","user":{"login":"devfans","id":13849768,"node_id":"MDQ6VXNlcjEzODQ5NzY4","avatar_url":"https://avatars3.githubusercontent.com/u/13849768?v=4","gravatar_id":"","url":"https://api.github.com/users/devfans","html_url":"https://github.com/devfans","followers_url":"https://api.github.com/users/devfans/followers","following_url":"https://api.github.com/users/devfans/following{/other_user}","gists_url":"https://api.github.com/users/devfans/gists{/gist_id}","starred_url":"https://api.github.com/users/devfans/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/devfans/subscriptions","organizations_url":"https://api.github.com/users/devfans/orgs","repos_url":"https://api.github.com/users/devfans/repos","events_url":"https://api.github.com/users/devfans/events{/privacy}","received_events_url":"https://api.github.com/users/devfans/received_events","type":"User","site_admin":false},"body":"Maybe redis end doesn't have such restriction, but the  crate`simple_redis` we are using only supports &str as parameters of `sismember`.","created_at":"2018-07-14T05:05:28Z","updated_at":"2018-07-14T05:05:28Z","html_url":"https://github.com/TheBlueMatt/mining-proxy/pull/14#discussion_r202506192","pull_request_url":"https://api.github.com/repos/TheBlueMatt/mining-proxy/pulls/14","author_association":"NONE","_links":{"self":{"href":"https://api.github.com/repos/TheBlueMatt/mining-proxy/pulls/comments/202506192"},"html":{"href":"https://github.com/TheBlueMatt/mining-proxy/pull/14#discussion_r202506192"},"pull_request":{"href":"https://api.github.com/repos/TheBlueMatt/mining-proxy/pulls/14"}},"in_reply_to_id":202505491},"pull_request":{"url":"https://api.github.com/repos/TheBlueMatt/mining-proxy/pulls/14","id":201338313,"node_id":"MDExOlB1bGxSZXF1ZXN0MjAxMzM4MzEz","html_url":"https://github.com/TheBlueMatt/mining-proxy/pull/14","diff_url":"https://github.com/TheBlueMatt/mining-proxy/pull/14.diff","patch_url":"https://github.com/TheBlueMatt/mining-proxy/pull/14.patch","issue_url":"https://api.github.com/repos/TheBlueMatt/mining-proxy/issues/14","number":14,"state":"open","locked":false,"title":"Add redis authenticator","user":{"login":"devfans","id":13849768,"node_id":"MDQ6VXNlcjEzODQ5NzY4","avatar_url":"https://avatars3.githubusercontent.com/u/13849768?v=4","gravatar_id":"","url":"https://api.github.com/users/devfans","html_url":"https://github.com/devfans","followers_url":"https://api.github.com/users/devfans/followers","following_url":"https://api.github.com/users/devfans/following{/other_user}","gists_url":"https://api.github.com/users/devfans/gists{/gist_id}","starred_url":"https://api.github.com/users/devfans/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/devfans/subscriptions","organizations_url":"https://api.github.com/users/devfans/orgs","repos_url":"https://api.github.com/users/devfans/repos","events_url":"https://api.github.com/users/devfans/events{/privacy}","received_events_url":"https://api.github.com/users/devfans/received_events","type":"User","site_admin":false},"body":"Split authentication from submitter, and add redis connector for authentication. The simple redis authenticator is to check if miner username is in a redis set with `sismember` command.\r\n","created_at":"2018-07-13T16:18:50Z","updated_at":"2018-07-14T05:05:28Z","closed_at":null,"merged_at":null,"merge_commit_sha":"7affd89d1422c7d0d688ef480375b185d7046a8f","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/TheBlueMatt/mining-proxy/pulls/14/commits","review_comments_url":"https://api.github.com/repos/TheBlueMatt/mining-proxy/pulls/14/comments","review_comment_url":"https://api.github.com/repos/TheBlueMatt/mining-proxy/pulls/comments{/number}","comments_url":"https://api.github.com/repos/TheBlueMatt/mining-proxy/issues/14/comments","statuses_url":"https://api.github.com/repos/TheBlueMatt/mining-proxy/statuses/63061085b8ce03444ff0d7dddcd0e31ddfebbeef","head":{"label":"devfans:dev-auth","ref":"dev-auth","sha":"63061085b8ce03444ff0d7dddcd0e31ddfebbeef","user":{"login":"devfans","id":13849768,"node_id":"MDQ6VXNlcjEzODQ5NzY4","avatar_url":"https://avatars3.githubusercontent.com/u/13849768?v=4","gravatar_id":"","url":"https://api.github.com/users/devfans","html_url":"https://github.com/devfans","followers_url":"https://api.github.com/users/devfans/followers","following_url":"https://api.github.com/users/devfans/following{/other_user}","gists_url":"https://api.github.com/users/devfans/gists{/gist_id}","starred_url":"https://api.github.com/users/devfans/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/devfans/subscriptions","organizations_url":"https://api.github.com/users/devfans/orgs","repos_url":"https://api.github.com/users/devfans/repos","events_url":"https://api.github.com/users/devfans/events{/privacy}","received_events_url":"https://api.github.com/users/devfans/received_events","type":"User","site_admin":false},"repo":{"id":139952955,"node_id":"MDEwOlJlcG9zaXRvcnkxMzk5NTI5NTU=","name":"mining-proxy","full_name":"devfans/mining-proxy","owner":{"login":"devfans","id":13849768,"node_id":"MDQ6VXNlcjEzODQ5NzY4","avatar_url":"https://avatars3.githubusercontent.com/u/13849768?v=4","gravatar_id":"","url":"https://api.github.com/users/devfans","html_url":"https://github.com/devfans","followers_url":"https://api.github.com/users/devfans/followers","following_url":"https://api.github.com/users/devfans/following{/other_user}","gists_url":"https://api.github.com/users/devfans/gists{/gist_id}","starred_url":"https://api.github.com/users/devfans/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/devfans/subscriptions","organizations_url":"https://api.github.com/users/devfans/orgs","repos_url":"https://api.github.com/users/devfans/repos","events_url":"https://api.github.com/users/devfans/events{/privacy}","received_events_url":"https://api.github.com/users/devfans/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/devfans/mining-proxy","description":"BetterHash Stratum+Pool Proxies and a Sample Pool","fork":true,"url":"https://api.github.com/repos/devfans/mining-proxy","forks_url":"https://api.github.com/repos/devfans/mining-proxy/forks","keys_url":"https://api.github.com/repos/devfans/mining-proxy/keys{/key_id}","collaborators_url":"https://api.github.com/repos/devfans/mining-proxy/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/devfans/mining-proxy/teams","hooks_url":"https://api.github.com/repos/devfans/mining-proxy/hooks","issue_events_url":"https://api.github.com/repos/devfans/mining-proxy/issues/events{/number}","events_url":"https://api.github.com/repos/devfans/mining-proxy/events","assignees_url":"https://api.github.com/repos/devfans/mining-proxy/assignees{/user}","branches_url":"https://api.github.com/repos/devfans/mining-proxy/branches{/branch}","tags_url":"https://api.github.com/repos/devfans/mining-proxy/tags","blobs_url":"https://api.github.com/repos/devfans/mining-proxy/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/devfans/mining-proxy/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/devfans/mining-proxy/git/refs{/sha}","trees_url":"https://api.github.com/repos/devfans/mining-proxy/git/trees{/sha}","statuses_url":"https://api.github.com/repos/devfans/mining-proxy/statuses/{sha}","languages_url":"https://api.github.com/repos/devfans/mining-proxy/languages","stargazers_url":"https://api.github.com/repos/devfans/mining-proxy/stargazers","contributors_url":"https://api.github.com/repos/devfans/mining-proxy/contributors","subscribers_url":"https://api.github.com/repos/devfans/mining-proxy/subscribers","subscription_url":"https://api.github.com/repos/devfans/mining-proxy/subscription","commits_url":"https://api.github.com/repos/devfans/mining-proxy/commits{/sha}","git_commits_url":"https://api.github.com/repos/devfans/mining-proxy/git/commits{/sha}","comments_url":"https://api.github.com/repos/devfans/mining-proxy/comments{/number}","issue_comment_url":"https://api.github.com/repos/devfans/mining-proxy/issues/comments{/number}","contents_url":"https://api.github.com/repos/devfans/mining-proxy/contents/{+path}","compare_url":"https://api.github.com/repos/devfans/mining-proxy/compare/{base}...{head}","merges_url":"https://api.github.com/repos/devfans/mining-proxy/merges","archive_url":"https://api.github.com/repos/devfans/mining-proxy/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/devfans/mining-proxy/downloads","issues_url":"https://api.github.com/repos/devfans/mining-proxy/issues{/number}","pulls_url":"https://api.github.com/repos/devfans/mining-proxy/pulls{/number}","milestones_url":"https://api.github.com/repos/devfans/mining-proxy/milestones{/number}","notifications_url":"https://api.github.com/repos/devfans/mining-proxy/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/devfans/mining-proxy/labels{/name}","releases_url":"https://api.github.com/repos/devfans/mining-proxy/releases{/id}","deployments_url":"https://api.github.com/repos/devfans/mining-proxy/deployments","created_at":"2018-07-06T08:01:50Z","updated_at":"2018-07-13T02:52:26Z","pushed_at":"2018-07-13T16:25:02Z","git_url":"git://github.com/devfans/mining-proxy.git","ssh_url":"git@github.com:devfans/mining-proxy.git","clone_url":"https://github.com/devfans/mining-proxy.git","svn_url":"https://github.com/devfans/mining-proxy","homepage":"","size":482,"stargazers_count":0,"watchers_count":0,"language":"Rust","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":null,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"TheBlueMatt:master","ref":"master","sha":"5317711ffdac371f376ded54a8257ac64ea68304","user":{"login":"TheBlueMatt","id":649246,"node_id":"MDQ6VXNlcjY0OTI0Ng==","avatar_url":"https://avatars0.githubusercontent.com/u/649246?v=4","gravatar_id":"","url":"https://api.github.com/users/TheBlueMatt","html_url":"https://github.com/TheBlueMatt","followers_url":"https://api.github.com/users/TheBlueMatt/followers","following_url":"https://api.github.com/users/TheBlueMatt/following{/other_user}","gists_url":"https://api.github.com/users/TheBlueMatt/gists{/gist_id}","starred_url":"https://api.github.com/users/TheBlueMatt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TheBlueMatt/subscriptions","organizations_url":"https://api.github.com/users/TheBlueMatt/orgs","repos_url":"https://api.github.com/users/TheBlueMatt/repos","events_url":"https://api.github.com/users/TheBlueMatt/events{/privacy}","received_events_url":"https://api.github.com/users/TheBlueMatt/received_events","type":"User","site_admin":false},"repo":{"id":124814394,"node_id":"MDEwOlJlcG9zaXRvcnkxMjQ4MTQzOTQ=","name":"mining-proxy","full_name":"TheBlueMatt/mining-proxy","owner":{"login":"TheBlueMatt","id":649246,"node_id":"MDQ6VXNlcjY0OTI0Ng==","avatar_url":"https://avatars0.githubusercontent.com/u/649246?v=4","gravatar_id":"","url":"https://api.github.com/users/TheBlueMatt","html_url":"https://github.com/TheBlueMatt","followers_url":"https://api.github.com/users/TheBlueMatt/followers","following_url":"https://api.github.com/users/TheBlueMatt/following{/other_user}","gists_url":"https://api.github.com/users/TheBlueMatt/gists{/gist_id}","starred_url":"https://api.github.com/users/TheBlueMatt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TheBlueMatt/subscriptions","organizations_url":"https://api.github.com/users/TheBlueMatt/orgs","repos_url":"https://api.github.com/users/TheBlueMatt/repos","events_url":"https://api.github.com/users/TheBlueMatt/events{/privacy}","received_events_url":"https://api.github.com/users/TheBlueMatt/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/TheBlueMatt/mining-proxy","description":"BetterHash Stratum+Pool Proxies and a Sample Pool","fork":false,"url":"https://api.github.com/repos/TheBlueMatt/mining-proxy","forks_url":"https://api.github.com/repos/TheBlueMatt/mining-proxy/forks","keys_url":"https://api.github.com/repos/TheBlueMatt/mining-proxy/keys{/key_id}","collaborators_url":"https://api.github.com/repos/TheBlueMatt/mining-proxy/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/TheBlueMatt/mining-proxy/teams","hooks_url":"https://api.github.com/repos/TheBlueMatt/mining-proxy/hooks","issue_events_url":"https://api.github.com/repos/TheBlueMatt/mining-proxy/issues/events{/number}","events_url":"https://api.github.com/repos/TheBlueMatt/mining-proxy/events","assignees_url":"https://api.github.com/repos/TheBlueMatt/mining-proxy/assignees{/user}","branches_url":"https://api.github.com/repos/TheBlueMatt/mining-proxy/branches{/branch}","tags_url":"https://api.github.com/repos/TheBlueMatt/mining-proxy/tags","blobs_url":"https://api.github.com/repos/TheBlueMatt/mining-proxy/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/TheBlueMatt/mining-proxy/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/TheBlueMatt/mining-proxy/git/refs{/sha}","trees_url":"https://api.github.com/repos/TheBlueMatt/mining-proxy/git/trees{/sha}","statuses_url":"https://api.github.com/repos/TheBlueMatt/mining-proxy/statuses/{sha}","languages_url":"https://api.github.com/repos/TheBlueMatt/mining-proxy/languages","stargazers_url":"https://api.github.com/repos/TheBlueMatt/mining-proxy/stargazers","contributors_url":"https://api.github.com/repos/TheBlueMatt/mining-proxy/contributors","subscribers_url":"https://api.github.com/repos/TheBlueMatt/mining-proxy/subscribers","subscription_url":"https://api.github.com/repos/TheBlueMatt/mining-proxy/subscription","commits_url":"https://api.github.com/repos/TheBlueMatt/mining-proxy/commits{/sha}","git_commits_url":"https://api.github.com/repos/TheBlueMatt/mining-proxy/git/commits{/sha}","comments_url":"https://api.github.com/repos/TheBlueMatt/mining-proxy/comments{/number}","issue_comment_url":"https://api.github.com/repos/TheBlueMatt/mining-proxy/issues/comments{/number}","contents_url":"https://api.github.com/repos/TheBlueMatt/mining-proxy/contents/{+path}","compare_url":"https://api.github.com/repos/TheBlueMatt/mining-proxy/compare/{base}...{head}","merges_url":"https://api.github.com/repos/TheBlueMatt/mining-proxy/merges","archive_url":"https://api.github.com/repos/TheBlueMatt/mining-proxy/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/TheBlueMatt/mining-proxy/downloads","issues_url":"https://api.github.com/repos/TheBlueMatt/mining-proxy/issues{/number}","pulls_url":"https://api.github.com/repos/TheBlueMatt/mining-proxy/pulls{/number}","milestones_url":"https://api.github.com/repos/TheBlueMatt/mining-proxy/milestones{/number}","notifications_url":"https://api.github.com/repos/TheBlueMatt/mining-proxy/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/TheBlueMatt/mining-proxy/labels{/name}","releases_url":"https://api.github.com/repos/TheBlueMatt/mining-proxy/releases{/id}","deployments_url":"https://api.github.com/repos/TheBlueMatt/mining-proxy/deployments","created_at":"2018-03-12T00:53:11Z","updated_at":"2018-07-13T16:15:02Z","pushed_at":"2018-07-13T16:25:03Z","git_url":"git://github.com/TheBlueMatt/mining-proxy.git","ssh_url":"git@github.com:TheBlueMatt/mining-proxy.git","clone_url":"https://github.com/TheBlueMatt/mining-proxy.git","svn_url":"https://github.com/TheBlueMatt/mining-proxy","homepage":"","size":433,"stargazers_count":16,"watchers_count":16,"language":"Rust","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":8,"mirror_url":null,"archived":false,"open_issues_count":9,"license":null,"forks":8,"open_issues":9,"watchers":16,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/TheBlueMatt/mining-proxy/pulls/14"},"html":{"href":"https://github.com/TheBlueMatt/mining-proxy/pull/14"},"issue":{"href":"https://api.github.com/repos/TheBlueMatt/mining-proxy/issues/14"},"comments":{"href":"https://api.github.com/repos/TheBlueMatt/mining-proxy/issues/14/comments"},"review_comments":{"href":"https://api.github.com/repos/TheBlueMatt/mining-proxy/pulls/14/comments"},"review_comment":{"href":"https://api.github.com/repos/TheBlueMatt/mining-proxy/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/TheBlueMatt/mining-proxy/pulls/14/commits"},"statuses":{"href":"https://api.github.com/repos/TheBlueMatt/mining-proxy/statuses/63061085b8ce03444ff0d7dddcd0e31ddfebbeef"}},"author_association":"NONE"}}
{"actor":{"display_login":"devfans"}}