[Pkg-privacy-commits] [Git][pkg-privacy-team/golang-goptlib][upstream] New upstream version 1.5.0

Danial Behzadi (@danialbehzadi) gitlab at salsa.debian.org
Wed Feb 21 23:18:42 GMT 2024



Danial Behzadi pushed to branch upstream at Privacy Maintainers / golang-goptlib


Commits:
b3e990ce by Danial Behzadi at 2024-02-22T01:55:58+03:30
New upstream version 1.5.0
- - - - -


6 changed files:

- ChangeLog
- README
- examples/dummy-client/dummy-client.go
- examples/dummy-server/dummy-server.go
- go.mod
- pt.go


Changes:

=====================================
ChangeLog
=====================================
@@ -1,3 +1,20 @@
+== v1.5.0
+
+Added the ReportVersion function that lets a client or server report its
+implementation version using the new STATUS TYPE=version feature.
+
+https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/goptlib/-/issues/1
+
+== v1.4.0
+
+Moved the repository URL from git.torproject.org/pluggable-transports/goptlib.git
+to gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/goptlib.
+
+== v1.3.0
+
+Added a DialOrWithDialer function that allows you to, for example, use a
+specific source address when dialing the ORPort.
+
 == v1.2.0
 
 The default and development branch is now "main" rather than "master".


=====================================
README
=====================================
@@ -1,12 +1,10 @@
 goptlib is a library for writing Tor pluggable transports in Go.
 
 https://spec.torproject.org/pt-spec
-https://gitweb.torproject.org/torspec.git/tree/proposals/196-transport-control-ports.txt
-https://gitweb.torproject.org/torspec.git/tree/proposals/217-ext-orport-auth.txt
-https://gitweb.torproject.org/torspec.git/tree/proposals/232-pluggable-transports-through-proxy.txt
+https://spec.torproject.org/ext-orport-spec
 
 To download a copy of the library into $GOPATH:
-	go get git.torproject.org/pluggable-transports/goptlib.git
+	go get gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/goptlib
 
 See the included example programs for examples of how to use the
 library. To build them, enter their directory and run "go build".
@@ -16,10 +14,10 @@ The recommended way to start writing a new transport plugin is to copy
 dummy-client or dummy-server and make changes to it.
 
 There is browseable documentation here:
-https://godoc.org/git.torproject.org/pluggable-transports/goptlib.git
+https://pkg.go.dev/gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/goptlib
 
 Report bugs to the tor-dev at lists.torproject.org mailing list or to the
-bug tracker at https://trac.torproject.org/projects/tor.
+bug tracker at https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/goptlib/-/issues.
 
 To the extent possible under law, the authors have dedicated all
 copyright and related and neighboring rights to this software to the


=====================================
examples/dummy-client/dummy-client.go
=====================================
@@ -20,7 +20,7 @@ import (
 	"syscall"
 )
 
-import "git.torproject.org/pluggable-transports/goptlib.git"
+import "gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/goptlib"
 
 var ptInfo pt.ClientInfo
 
@@ -80,6 +80,8 @@ func main() {
 		os.Exit(1)
 	}
 
+	pt.ReportVersion("dummy-client", "0.1")
+
 	if ptInfo.ProxyURL != nil {
 		pt.ProxyError("proxy is not supported")
 		os.Exit(1)


=====================================
examples/dummy-server/dummy-server.go
=====================================
@@ -21,7 +21,7 @@ import (
 	"syscall"
 )
 
-import "git.torproject.org/pluggable-transports/goptlib.git"
+import "gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/goptlib"
 
 var ptInfo pt.ServerInfo
 
@@ -77,6 +77,8 @@ func main() {
 		os.Exit(1)
 	}
 
+	pt.ReportVersion("dummy-server", "0.1")
+
 	listeners := make([]net.Listener, 0)
 	for _, bindaddr := range ptInfo.Bindaddrs {
 		switch bindaddr.MethodName {


=====================================
go.mod
=====================================
@@ -1,3 +1,3 @@
-module git.torproject.org/pluggable-transports/goptlib.git
+module gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/goptlib
 
 go 1.11


=====================================
pt.go
=====================================
@@ -36,6 +36,7 @@
 // 	...
 // 	func main() {
 // 		var err error
+// 		pt.ReportVersion("program", "v1.0")
 // 		ptInfo, err = pt.ClientSetup(nil)
 // 		if err != nil {
 // 			os.Exit(1)
@@ -94,6 +95,7 @@
 // 	...
 // 	func main() {
 // 		var err error
+// 		pt.ReportVersion("program", "v1.0")
 // 		ptInfo, err = pt.ServerSetup(nil)
 // 		if err != nil {
 // 			os.Exit(1)
@@ -122,13 +124,7 @@
 // https://spec.torproject.org/pt-spec
 //
 // Extended ORPort:
-// https://gitweb.torproject.org/torspec.git/tree/proposals/196-transport-control-ports.txt
-//
-// Extended ORPort Authentication:
-// https://gitweb.torproject.org/torspec.git/tree/proposals/217-ext-orport-auth.txt
-//
-// Pluggable Transport through SOCKS proxy:
-// https://gitweb.torproject.org/torspec.git/tree/proposals/232-pluggable-transports-through-proxy.txt
+// https://spec.torproject.org/ext-orport-spec
 //
 // The package implements a SOCKS5 server sufficient for a Tor client transport
 // plugin.
@@ -349,6 +345,15 @@ func ProxyDone() {
 	fmt.Fprintf(Stdout, "PROXY DONE\n")
 }
 
+// Report this program's name and version number using a STATUS TYPE=version
+// line. Can be called any time before calling CmethodsDone or SmethodsDone.
+//
+// When called in a pluggable transport server, the implementation name and
+// version number will appear in the relay's bridge-extra-info descriptor.
+func ReportVersion(implementation string, version string) {
+	line("STATUS", "TYPE=version", "IMPLEMENTATION="+encodeCString(implementation), "VERSION="+encodeCString(version))
+}
+
 // Unexported type to represent log severities, preventing external callers from
 // inventing new severity strings that may violate quoting rules.
 //
@@ -680,7 +685,7 @@ func readAuthCookie(f io.Reader) ([]byte, error) {
 }
 
 // Read and validate the contents of an auth cookie file. Returns the 32-byte
-// cookie. See section 4.2.1.2 of 217-ext-orport-auth.txt.
+// cookie. See section 2.1.2 of ext-orport-spec.txt.
 func readAuthCookieFile(filename string) (cookie []byte, err error) {
 	f, err := os.Open(filename)
 	if err != nil {
@@ -770,7 +775,7 @@ func ServerSetup(_ []string) (info ServerInfo, err error) {
 	return info, nil
 }
 
-// See 217-ext-orport-auth.txt section 4.2.1.3.
+// See ext-orport-spec.txt section 2.1.3.
 func computeServerHash(authCookie, clientNonce, serverNonce []byte) []byte {
 	h := hmac.New(sha256.New, authCookie)
 	io.WriteString(h, "ExtORPort authentication server-to-client hash")
@@ -779,7 +784,7 @@ func computeServerHash(authCookie, clientNonce, serverNonce []byte) []byte {
 	return h.Sum([]byte{})
 }
 
-// See 217-ext-orport-auth.txt section 4.2.1.3.
+// See ext-orport-spec.txt section 2.1.3.
 func computeClientHash(authCookie, clientNonce, serverNonce []byte) []byte {
 	h := hmac.New(sha256.New, authCookie)
 	io.WriteString(h, "ExtORPort authentication client-to-server hash")
@@ -789,7 +794,7 @@ func computeClientHash(authCookie, clientNonce, serverNonce []byte) []byte {
 }
 
 func extOrPortAuthenticate(s io.ReadWriter, info *ServerInfo) error {
-	// Read auth types. 217-ext-orport-auth.txt section 4.1.
+	// Read auth types. ext-orport-spec.txt section 2.
 	var authTypes [256]bool
 	var count int
 	for count = 0; count < 256; count++ {
@@ -872,7 +877,7 @@ func extOrPortAuthenticate(s io.ReadWriter, info *ServerInfo) error {
 	return nil
 }
 
-// See section 3.1.1 of 196-transport-control-ports.txt.
+// See section 3.1 of ext-orport-spec.txt.
 const (
 	extOrCmdDone      = 0x0000
 	extOrCmdUserAddr  = 0x0001
@@ -906,19 +911,17 @@ func extOrPortSendCommand(s io.Writer, cmd uint16, body []byte) error {
 	return nil
 }
 
-// Send a USERADDR command on s. See section 3.1.2.1 of
-// 196-transport-control-ports.txt.
+// Send a USERADDR command on s. See section 3.2.1 of ext-orport-spec.txt.
 func extOrPortSendUserAddr(s io.Writer, addr string) error {
 	return extOrPortSendCommand(s, extOrCmdUserAddr, []byte(addr))
 }
 
-// Send a TRANSPORT command on s. See section 3.1.2.2 of
-// 196-transport-control-ports.txt.
+// Send a TRANSPORT command on s. See section 3.2.2 of ext-orport-spec.txt.
 func extOrPortSendTransport(s io.Writer, methodName string) error {
 	return extOrPortSendCommand(s, extOrCmdTransport, []byte(methodName))
 }
 
-// Send a DONE command on s. See section 3.1 of 196-transport-control-ports.txt.
+// Send a DONE command on s. See section 3.1 of ext-orport-spec.txt.
 func extOrPortSendDone(s io.Writer) error {
 	return extOrPortSendCommand(s, extOrCmdDone, []byte{})
 }
@@ -987,7 +990,7 @@ func extOrPortSetMetadata(s io.ReadWriter, addr, methodName string) error {
 
 func extOrPortSetup(s net.Conn, timeout time.Duration,
 	info *ServerInfo, addr, methodName string) error {
-	err := s.SetDeadline(time.Now().Add(5 * time.Second))
+	err := s.SetDeadline(time.Now().Add(timeout))
 	if err != nil {
 		return err
 	}
@@ -1006,20 +1009,20 @@ func extOrPortSetup(s net.Conn, timeout time.Duration,
 	return nil
 }
 
-// Dial info.ExtendedOrAddr if defined, or else info.OrAddr, and return an open
-// *net.TCPConn. If connecting to the extended OR port, extended OR port
-// authentication à la 217-ext-orport-auth.txt is done before returning; an
-// error is returned if authentication fails.
+// Dial (using the given net.Dialer) info.ExtendedOrAddr if defined, or else
+// info.OrAddr, and return an open net.Conn. If connecting to the extended OR
+// port, extended OR port authentication is done before returning; an error is
+// returned if authentication fails.
 //
 // The addr and methodName arguments are put in USERADDR and TRANSPORT ExtOrPort
 // commands, respectively. If either is "", the corresponding command is not
 // sent.
-func DialOr(info *ServerInfo, addr, methodName string) (*net.TCPConn, error) {
+func DialOrWithDialer(dialer *net.Dialer, info *ServerInfo, addr, methodName string) (net.Conn, error) {
 	if info.ExtendedOrAddr == nil || info.AuthCookiePath == "" {
-		return net.DialTCP("tcp", nil, info.OrAddr)
+		return dialer.Dial("tcp", info.OrAddr.String())
 	}
 
-	s, err := net.DialTCP("tcp", nil, info.ExtendedOrAddr)
+	s, err := dialer.Dial("tcp", info.ExtendedOrAddr.String())
 	if err != nil {
 		return nil, err
 	}
@@ -1031,3 +1034,16 @@ func DialOr(info *ServerInfo, addr, methodName string) (*net.TCPConn, error) {
 
 	return s, nil
 }
+
+// Dial info.ExtendedOrAddr if defined, or else info.OrAddr, and return an open
+// *net.TCPConn. If connecting to the extended OR port, extended OR port
+// authentication is done before returning; an error is returned if
+// authentication fails.
+//
+// The addr and methodName arguments are put in USERADDR and TRANSPORT ExtOrPort
+// commands, respectively. If either is "", the corresponding command is not
+// sent.
+func DialOr(info *ServerInfo, addr, methodName string) (*net.TCPConn, error) {
+	c, err := DialOrWithDialer(&net.Dialer{}, info, addr, methodName)
+	return c.(*net.TCPConn), err
+}



View it on GitLab: https://salsa.debian.org/pkg-privacy-team/golang-goptlib/-/commit/b3e990cea5c0fdf9ab31a0618d39698800589e9e

-- 
View it on GitLab: https://salsa.debian.org/pkg-privacy-team/golang-goptlib/-/commit/b3e990cea5c0fdf9ab31a0618d39698800589e9e
You're receiving this email because of your account on salsa.debian.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/pkg-privacy-commits/attachments/20240221/7c856f1c/attachment-0001.htm>


More information about the Pkg-privacy-commits mailing list