9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* [9fans] [PATCH] p9p: 9pserve proxy support
@ 2008-06-11 12:49 Enrico Weigelt
  0 siblings, 0 replies; only message in thread
From: Enrico Weigelt @ 2008-06-11 12:49 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

[-- Attachment #1: Type: text/plain, Size: 768 bytes --]


Hi folks,


here's a patch against p9p for an "proxy mode" in 9pserve, like Russ
suggested. It just adds an new "-c" option which tells 9pserve to
dial to an address as it's input connection (instead of taking stdio).

This way, 9pserve can eg. be used as a proxy between a unix socket
and TCP, making p9p servers available via TCP.

cu
--
----------------------------------------------------------------------
 Enrico Weigelt, metux IT service -- http://www.metux.de/

 cellphone: +49 174 7066481   email: info@metux.de   skype: nekrad666
----------------------------------------------------------------------
 Embedded-Linux / Portierung / Opensource-QM / Verteilte Systeme
----------------------------------------------------------------------

[-- Attachment #2: 9pserve-pipe.diff --]
[-- Type: text/plain, Size: 882 bytes --]

Index: src/cmd/9pserve.c
===================================================================
--- src/cmd/9pserve.c	(revision 707)
+++ src/cmd/9pserve.c	(working copy)
@@ -136,7 +136,7 @@
 void
 usage(void)
 {
-	fprint(2, "usage: 9pserve [-lnv] [-A aname afid] [-M msize] address\n");
+	fprint(2, "usage: 9pserve [-c pipe] [-lnv] [-A aname afid] [-M msize] address\n");
 	fprint(2, "\treads/writes 9P messages on stdin/stdout\n");
 	threadexitsall("usage");
 }
@@ -157,6 +157,19 @@
 	ARGBEGIN{
 	default:
 		usage();
+	case 'c':
+	{
+		char* pipename = EARGF(usage());
+		printf("pipename=\"%s\"\n", pipename);
+
+                if((fd = dial(pipename, nil, nil, nil)) < 0)
+            	    sysfatal("dial %s: %r");
+		dup(fd, 0);
+		dup(fd, 1);
+		if(fd > 1)
+		    close(fd);
+	}
+	break;
 	case 'A':
 		attached = 1;
 		xaname = EARGF(usage());

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2008-06-11 12:49 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-06-11 12:49 [9fans] [PATCH] p9p: 9pserve proxy support Enrico Weigelt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).