Skip to content

Commit

Permalink
integrate starbridge pt
Browse files Browse the repository at this point in the history
  • Loading branch information
myleshorton committed Oct 13, 2022
1 parent fb11037 commit 6032fc7
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 3 deletions.
2 changes: 2 additions & 0 deletions chained/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,8 @@ func createImpl(configDir, name, addr, transport string, s *apipb.ProxyConfig, u
impl, err = newWSSImpl(addr, s, reportDialCore)
case "tlsmasq":
impl, err = newTLSMasqImpl(configDir, name, addr, s, uc, reportDialCore)
case "starbridge":
impl, err = newStarbridgeImpl(name, addr, s, reportDialCore)
default:
err = errors.New("Unknown transport: %v", transport).With("addr", addr).With("plugabble-transport", transport)
}
Expand Down
3 changes: 1 addition & 2 deletions chained/shadowsocks_impl.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
//go:build !iosapp
// +build !iosapp

package chained

Expand All @@ -18,8 +17,8 @@ import (
"github.com/getlantern/errors"
shadowsocks "github.com/getlantern/lantern-shadowsocks/client"

"github.com/getlantern/lantern-cloud/cmd/api/apipb"
"github.com/getlantern/flashlight/ops"
"github.com/getlantern/lantern-cloud/cmd/api/apipb"
)

const (
Expand Down
44 changes: 44 additions & 0 deletions chained/starbridge_impl.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package chained

import (
"context"
"net"

"github.com/OperatorFoundation/Starbridge-go/Starbridge/v3"
"github.com/getlantern/flashlight/ops"
"github.com/getlantern/lantern-cloud/cmd/api/apipb"
)

type starbridge struct {
reportDialCore reportDialCoreFn
config Starbridge.ClientConfig
conn net.Conn
}

func (s *starbridge) dialServer(op *ops.Op, ctx context.Context) (net.Conn, error) {
return s.reportDialCore(op, func() (net.Conn, error) {
conn, err := s.config.Dial(s.config.Address)
if err != nil {
return nil, err
}
s.conn = conn
return conn, nil
})
}

func (s *starbridge) close() {
if s.conn != nil {
s.conn.Close()
}
}

func newStarbridgeImpl(name, addr string, pc *apipb.ProxyConfig, reportDialCore reportDialCoreFn) (proxyImpl, error) {
config := Starbridge.ClientConfig{
Address: addr,
ServerPersistentPublicKey: pc.Cert,
}
return &starbridge{
config: config,
reportDialCore: reportDialCore,
}, nil
}
13 changes: 12 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -135,12 +135,23 @@ require (

require github.com/getlantern/libp2p v0.0.0-20220913092210-f9e794d6b10d

require golang.org/x/exp v0.0.0-20220428152302-39d4317da171 // indirect
require (
github.com/OperatorFoundation/Replicant-go/Replicant/v3 v3.0.8 // indirect
github.com/OperatorFoundation/ghostwriter-go v1.0.6 // indirect
github.com/OperatorFoundation/go-bloom v1.0.1 // indirect
github.com/OperatorFoundation/go-shadowsocks2 v1.1.11 // indirect
github.com/OperatorFoundation/monolith-go/monolith v1.0.10 // indirect
github.com/OperatorFoundation/shapeshifter-ipc/v3 v3.0.0 // indirect
github.com/aead/ecdh v0.2.0 // indirect
github.com/deckarep/golang-set v1.8.0 // indirect
golang.org/x/exp v0.0.0-20220428152302-39d4317da171 // indirect
)

require (
crawshaw.io/sqlite v0.3.3-0.20210127221821-98b1f83c5508 // indirect
filippo.io/edwards25519 v1.0.0-rc.1.0.20210721174708-390f27c3be20 // indirect
github.com/HdrHistogram/hdrhistogram-go v1.1.0 // indirect
github.com/OperatorFoundation/Starbridge-go/Starbridge/v3 v3.0.9
github.com/RoaringBitmap/roaring v1.0.1-0.20220510143707-3f418c4f42a4 // indirect
github.com/Yawning/chacha20 v0.0.0-20170904085104-e3b1f968fc63 // indirect
github.com/ajwerner/btree v0.0.0-20211221152037-f427b3e689c0 // indirect
Expand Down
19 changes: 19 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,20 @@ github.com/FZambia/sentinel v1.0.0/go.mod h1:ytL1Am/RLlAoAXG6Kj5LNuw/TRRQrv2rt2F
github.com/HdrHistogram/hdrhistogram-go v1.1.0 h1:6dpdDPTRoo78HxAJ6T1HfMiKSnqhgRRqzCuPshRkQ7I=
github.com/HdrHistogram/hdrhistogram-go v1.1.0/go.mod h1:yDgFjdqOqDEKOvasDdhWNXYg9BVp4O+o5f6V/ehm6Oo=
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
github.com/OperatorFoundation/Replicant-go/Replicant/v3 v3.0.8 h1:INPCMf38hpu96erwK7zz8fkFR7wnP/LdmZbYIkr3a1I=
github.com/OperatorFoundation/Replicant-go/Replicant/v3 v3.0.8/go.mod h1:sY1hyotmn8xpQryUVXBC4ASWBeN2nTMV9VKlBoYy0x8=
github.com/OperatorFoundation/Starbridge-go/Starbridge/v3 v3.0.9 h1:P/vq2B9Kku/4HqWKJrCSUhWHUcx72PeYMeZzL4319PU=
github.com/OperatorFoundation/Starbridge-go/Starbridge/v3 v3.0.9/go.mod h1:IFVf+l8HEl+GwIqyfWqMCa8TBrPBw4Gp/fBDoyTNfB4=
github.com/OperatorFoundation/ghostwriter-go v1.0.6 h1:2E5D4qDKwsV+LQoKGtgIyjq5JvMiBZf8ySR8q0PP4vc=
github.com/OperatorFoundation/ghostwriter-go v1.0.6/go.mod h1:+uejzC1RRxZwngnCArqZX3d7i6ZX4Si8jNG8G6oCIKQ=
github.com/OperatorFoundation/go-bloom v1.0.1 h1:8q/rfgfG7OvwGkmzusIuV8PlS8MvA/T0kQ2MXm9371g=
github.com/OperatorFoundation/go-bloom v1.0.1/go.mod h1:b6bJWAnYIhwDgFIIolHyeuTYbPWAYj1Lnnwvcoa7P38=
github.com/OperatorFoundation/go-shadowsocks2 v1.1.11 h1:e9StBRZeyF9mZ+4y3JTtqN+rETMVMG3eaZj+3ZwIfGY=
github.com/OperatorFoundation/go-shadowsocks2 v1.1.11/go.mod h1:yw8jel8UNDWkJNE3wwAfEyctdCw6DI1FWBrZgcuoBfI=
github.com/OperatorFoundation/monolith-go/monolith v1.0.10 h1:mK7X57x5LliwsPmRoWgdVhMK1u+ag3LaxemsYpQ279Y=
github.com/OperatorFoundation/monolith-go/monolith v1.0.10/go.mod h1:czRPOIH/In5SEcnHndvit7O+Pq+rHxkrE5XqwYhIkqo=
github.com/OperatorFoundation/shapeshifter-ipc/v3 v3.0.0 h1:zeWIkAC4NH9X49wLg75yKw4g5p3Gq8ZYTWxbXGeinCs=
github.com/OperatorFoundation/shapeshifter-ipc/v3 v3.0.0/go.mod h1:N/8omY/NE0qGcbNhadLjgxmfwo3/Vg8XkOAnhpZ9BIM=
github.com/PuerkitoBio/goquery v1.7.0 h1:O5SP3b9JWqMSVMG69zMfj577zwkSNpxrFf7ybS74eiw=
github.com/PuerkitoBio/goquery v1.7.0/go.mod h1:GsLWisAFVj4WgDibEWF4pvYnkVQBpKBKeU+7zCJoLcc=
github.com/RoaringBitmap/roaring v0.4.7/go.mod h1:8khRDP4HmeXns4xIj9oGrKSz7XTQiJx2zgh7AcNke4w=
Expand All @@ -73,6 +87,8 @@ github.com/StackExchange/wmi v0.0.0-20210224194228-fe8f1750fd46/go.mod h1:3eOhrU
github.com/Workiva/go-datastructures v1.0.53/go.mod h1:1yZL+zfsztete+ePzZz/Zb1/t5BnDuE2Ya2MMGhzP6A=
github.com/Yawning/chacha20 v0.0.0-20170904085104-e3b1f968fc63 h1:I6/SJSN9wJMJ+ZyQaCHUlzoTA4ypU5Bb44YWR1wTY/0=
github.com/Yawning/chacha20 v0.0.0-20170904085104-e3b1f968fc63/go.mod h1:nf+Komq6fVP4SwmKEaVGxHTyQGKREVlwjQKpvOV39yE=
github.com/aead/ecdh v0.2.0 h1:pYop54xVaq/CEREFEcukHRZfTdjiWvYIsZDXXrBapQQ=
github.com/aead/ecdh v0.2.0/go.mod h1:a9HHtXuSo8J1Js1MwLQx2mBhkXMT6YwUmVVEY4tTB8U=
github.com/ajstarks/svgo v0.0.0-20180226025133-644b8db467af/go.mod h1:K08gAheRH3/J6wwsYMMT4xOr94bZjxIelGM0+d/wbFw=
github.com/ajwerner/btree v0.0.0-20211221152037-f427b3e689c0 h1:byYvvbfSo3+9efR4IeReh77gVs4PnNDR3AMOE9NJ7a0=
github.com/ajwerner/btree v0.0.0-20211221152037-f427b3e689c0/go.mod h1:q37NoqncT41qKc048STsifIt69LfUJ8SrWWcz/yam5k=
Expand Down Expand Up @@ -239,6 +255,8 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/dchest/siphash v1.2.1 h1:4cLinnzVJDKxTCl9B01807Yiy+W7ZzVHj/KIroQRvT4=
github.com/dchest/siphash v1.2.1/go.mod h1:q+IRvb2gOSrUnYoPqHiyHXS0FOBBOdl6tONBlVnOnt4=
github.com/deckarep/golang-set v1.8.0 h1:sk9/l/KqpunDwP7pSjUg0keiOOLEnOBHzykLrsPppp4=
github.com/deckarep/golang-set v1.8.0/go.mod h1:5nI87KwE7wgsBU1F4GKAw2Qod7p5kyS383rP6+o6qqo=
github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78=
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc=
Expand Down Expand Up @@ -1225,6 +1243,7 @@ golang.org/x/build v0.0.0-20190111050920-041ab4dc3f9d/go.mod h1:OWs+y06UdEOHN4y+
golang.org/x/crypto v0.0.0-20180723164146-c126467f60eb/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/crypto v0.0.0-20181030102418-4d3f4d9ffa16/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/crypto v0.0.0-20190211182817-74369b46fc67/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20190313024323-a1f597ede03a/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
Expand Down

0 comments on commit 6032fc7

Please sign in to comment.