Browse Source

Expose HTTP getwork username in Manage TUI and devdetails RPC

Luke Dashjr 12 years ago
parent
commit
b0ca648a52
1 changed files with 16 additions and 3 deletions
  1. 16 3
      driver-getwork.c

+ 16 - 3
driver-getwork.c

@@ -38,7 +38,6 @@ static
 pthread_mutex_t getwork_clients_mutex;
 pthread_mutex_t getwork_clients_mutex;
 
 
 // TODO: X-Hashes-Done?
 // TODO: X-Hashes-Done?
-// TODO: TUI manage username display
 // TODO: block getworks if disabled?
 // TODO: block getworks if disabled?
 // TODO: maybe reject known-stale shares?
 // TODO: maybe reject known-stale shares?
 
 
@@ -163,17 +162,20 @@ int handle_getwork(struct MHD_Connection *conn, bytes_t *upbuf)
 	if (!client)
 	if (!client)
 	{
 	{
 		cgpu = malloc(sizeof(*cgpu));
 		cgpu = malloc(sizeof(*cgpu));
+		client = malloc(sizeof(*client));
 		*cgpu = (struct cgpu_info){
 		*cgpu = (struct cgpu_info){
 			.drv = &getwork_drv,
 			.drv = &getwork_drv,
 			.threads = 0,
 			.threads = 0,
+			.device_data = client,
+			.device_path = user,
 		};
 		};
 		if (unlikely(!create_new_cgpus(add_cgpu_live, cgpu)))
 		if (unlikely(!create_new_cgpus(add_cgpu_live, cgpu)))
 		{
 		{
+			free(client);
 			free(cgpu);
 			free(cgpu);
 			ret = getwork_error(conn, -32603, "Failed creating new cgpu", idstr, idstr_sz);
 			ret = getwork_error(conn, -32603, "Failed creating new cgpu", idstr, idstr_sz);
 			goto out;
 			goto out;
 		}
 		}
-		client = malloc(sizeof(*client));
 		*client = (struct getwork_client){
 		*client = (struct getwork_client){
 			.username = user,
 			.username = user,
 			.cgpu = cgpu,
 			.cgpu = cgpu,
@@ -265,8 +267,19 @@ out:
 	return ret;
 	return ret;
 }
 }
 
 
+#ifdef HAVE_CURSES
+static
+void getwork_wlogprint_status(struct cgpu_info *cgpu)
+{
+	struct getwork_client *client = cgpu->device_data;
+	wlogprint("Username: %s\n", client->username);
+}
+#endif
+
 struct device_drv getwork_drv = {
 struct device_drv getwork_drv = {
 	.dname = "getwork",
 	.dname = "getwork",
 	.name = "SGW",
 	.name = "SGW",
-// 	.get_api_stats = getwork_stats,
+#ifdef HAVE_CURSES
+	.proc_wlogprint_status = getwork_wlogprint_status,
+#endif
 };
 };