[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [goptlib/master] Add an example of using SmethodArgs.
commit f39e775a2933f965d7fc9a673309b502a2420595
Author: David Fifield <david@xxxxxxxxxxxxxxx>
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))
}
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits