aboutsummaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorCecylia Bocovich <cohosh@torproject.org>2021-09-09 12:54:31 -0400
committerCecylia Bocovich <cohosh@torproject.org>2021-10-04 10:17:37 -0400
commit99887cd05d830896d2b2cda9809e4ff1a2836c93 (patch)
tree1aa410a337381a3efa504340b7afbb56d7cd6a97 /doc
parent624750d5a8a0b0acedd495168bcb2b5fc627fcb8 (diff)
downloadsnowflake-99887cd05d830896d2b2cda9809e4ff1a2836c93.tar.gz
snowflake-99887cd05d830896d2b2cda9809e4ff1a2836c93.zip
Add package functions to define and set the rendezvous method
Add exported functions to the snowflake client library to allow calling programs to define and set their own custom broker rendezvous methods.
Diffstat (limited to 'doc')
-rw-r--r--doc/using-the-snowflake-library.md54
1 files changed, 54 insertions, 0 deletions
diff --git a/doc/using-the-snowflake-library.md b/doc/using-the-snowflake-library.md
index 9308cdc..4dc47fc 100644
--- a/doc/using-the-snowflake-library.md
+++ b/doc/using-the-snowflake-library.md
@@ -38,6 +38,60 @@ func main() {
}
```
+#### Using your own rendezvous method
+
+You can define and use your own rendezvous method to communicate with a Snowflake broker by implementing the `RendezvousMethod` interface.
+
+```Golang
+
+package main
+
+import (
+ "log"
+
+ sf "git.torproject.org/pluggable-transports/snowflake.git/client/lib"
+)
+
+type StubMethod struct {
+}
+
+func (m *StubMethod) Exchange(pollReq []byte) ([]byte, error) {
+ var brokerResponse []byte
+ var err error
+
+ //Implement the logic you need to communicate with the Snowflake broker here
+
+ return brokerResponse, err
+}
+
+func main() {
+ config := sf.ClientConfig{
+ ICEAddresses: []string{
+ "stun:stun.voip.blackberry.com:3478",
+ "stun:stun.stunprotocol.org:3478"},
+ }
+ transport, err := sf.NewSnowflakeClient(config)
+ if err != nil {
+ log.Fatal("Failed to start snowflake transport: ", err)
+ }
+
+ // custom rendezvous methods can be set with `SetRendezvousMethod`
+ rendezvous := &StubMethod{}
+ transport.SetRendezvousMethod(rendezvous)
+
+ // transport implements the ClientFactory interface and returns a net.Conn
+ conn, err := transport.Dial()
+ if err != nil {
+ log.Printf("dial error: %s", err)
+ return
+ }
+ defer conn.Close()
+
+ // ...
+
+}
+```
+
### Server library
The Snowflake server library contains functions for running a Snowflake server.