[tor-commits] [goptlib/master] Add an example of using SmethodArgs.
dcf at torproject.org
dcf at torproject.org
Mon Dec 9 02:49:51 UTC 2013
commit f39e775a2933f965d7fc9a673309b502a2420595
Author: David Fifield <david at bamsoftware.com>
Date: Sun Dec 8 18:28:54 2013 -0800
Add an example of using SmethodArgs.
---
pt.go | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/pt.go b/pt.go
index d415480..39e7471 100644
--- a/pt.go
+++ b/pt.go
@@ -262,6 +262,19 @@ func Smethod(name string, addr net.Addr) {
// Emit an SMETHOD line with an ARGS option. args is a nameâvalue mapping that
// will be added to the server's extrainfo document.
+//
+// This is an example of how to check for a required option:
+// args := pt.Args{}
+// secret, ok := bindaddr.Options.Get("shared-secret")
+// if !ok {
+// pt.SmethodError(bindaddr.MethodName, "need a shared-secret option")
+// continue
+// }
+// args.Add("shared-secret", secret)
+// pt.SmethodArgs(bindaddr.MethodName, ln.Addr(), args)
+// Or, if you just want to echo back the options provided by Tor from the
+// TransportServerOptions configuration,
+// pt.SmethodArgs(bindaddr.MethodName, ln.Addr(), bindaddr.Options)
func SmethodArgs(name string, addr net.Addr, args Args) {
line("SMETHOD", name, addr.String(), "ARGS:"+encodeSmethodArgs(args))
}
More information about the tor-commits
mailing list