Skip to content

Commit

Permalink
began implementation of make server address part of transport config
Browse files Browse the repository at this point in the history
  • Loading branch information
CryptoSax committed Jul 27, 2020
1 parent 4ab5b8d commit ab9d528
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 26 deletions.
42 changes: 18 additions & 24 deletions transports/Replicant/v3/Optimizer.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ package replicant

import (
pt "github.com/OperatorFoundation/shapeshifter-ipc/v2"
"github.com/kataras/golog"
"golang.org/x/net/proxy"
"net"
)
Expand All @@ -36,31 +35,27 @@ type TransportClient struct {
Config ClientConfig
Address string
Dialer proxy.Dialer
Log *golog.Logger
}

type TransportServer struct {
Config ServerConfig
Config ServerConfig
Address string
Dialer proxy.Dialer
Log *golog.Logger
}

func NewClient(config ClientConfig, address string, dialer proxy.Dialer, log *golog.Logger) TransportClient {
func NewClient(config ClientConfig, dialer proxy.Dialer) TransportClient {
return TransportClient{
Config: config,
Address: address,
Dialer: dialer,
Log: log,
Config: config,
Address: config.Address,
Dialer: dialer,
}
}

func NewServer(config ServerConfig, address string, dialer proxy.Dialer, log *golog.Logger) TransportServer {
func NewServer(config ServerConfig, address string, dialer proxy.Dialer) TransportServer {
return TransportServer{
Config: config,
Config: config,
Address: address,
Dialer: dialer,
Log: log,
Dialer: dialer,
}
}

Expand All @@ -78,7 +73,7 @@ func (transport TransportClient) Dial() (net.Conn, error) {
}

return transportConn, nil
}
}

func (transport TransportServer) Listen() (net.Listener, error) {
addr, resolveErr := pt.ResolveAddr(transport.Address)
Expand All @@ -93,14 +88,13 @@ func (transport TransportServer) Listen() (net.Listener, error) {

return newReplicantTransportListener(ln, transport.Config), nil
}
//replicantTransport := New(transport.Config, transport.Dialer)
//conn := replicantTransport.Dial(transport.Address)
//conn, err:= replicantTransport.Dial(transport.Address), errors.New("connection failed")
//if err != nil {
// return nil, err
//} else {
// return conn, nil
//}
//return conn, nil


//replicantTransport := New(transport.Config, transport.Dialer)
//conn := replicantTransport.Dial(transport.Address)
//conn, err:= replicantTransport.Dial(transport.Address), errors.New("connection failed")
//if err != nil {
// return nil, err
//} else {
// return conn, nil
//}
//return conn, nil
2 changes: 2 additions & 0 deletions transports/Replicant/v3/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import (
type ClientConfig struct {
Toneburst toneburst.Config
Polish polish.ClientConfig
Address string
}

type ServerConfig struct {
Expand Down Expand Up @@ -70,6 +71,7 @@ func (config ClientConfig) Marshal() (string, error) {

type ClientJSONConfig struct {
Config string `json:"config"`
Address string `json:"address"`
}

configString, configStringError := config.Encode()
Expand Down
1 change: 1 addition & 0 deletions transports/Replicant/v3/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ go 1.12
require (
github.com/OperatorFoundation/monolith-go/monolith v1.0.4
github.com/OperatorFoundation/shapeshifter-ipc/v2 v2.0.0
github.com/kataras/golog v0.0.18
github.com/opentracing/opentracing-go v1.1.0
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2
golang.org/x/net v0.0.0-20200202094626-16171245cfb2
Expand Down
6 changes: 4 additions & 2 deletions transports/Replicant/v3/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ github.com/OperatorFoundation/shapeshifter-ipc/v2 v2.0.0 h1:6aQs+TF3KULMarpzbKu8
github.com/OperatorFoundation/shapeshifter-ipc/v2 v2.0.0/go.mod h1:gb/QiZH0QDXLSQ9PskyJ2oTflB7tsP4AYc8y+FppvB0=
github.com/deckarep/golang-set v1.7.1 h1:SCQV0S6gTtp6itiFrTqI+pfmJ4LN85S1YzhDf9rTHJQ=
github.com/deckarep/golang-set v1.7.1/go.mod h1:93vsz/8Wt4joVM7c2AVqh+YRMiUSc14yDtF28KmMOgQ=
h1:lDH9UUVJtmYCjyT0CI4q8xvlXPxeZ0gYCVvWbmPlp88=
/go.mod h1:HzydrMdWErDVzsI23lYNej1Htcns9BCg93Dk0bBINWk=
github.com/kataras/golog v0.0.18 h1:Td7hcKN25yzqB/0SO5iohOsMk5Mq5V9kDtM5apaJLY0=
github.com/kataras/golog v0.0.18/go.mod h1:jRYl7dFYqP8aQj9VkwdBUXYZSfUktm+YYg1arJILfyw=
github.com/kataras/pio v0.0.8 h1:6pX6nHJk7DAV3x1dEimibQF2CmJLlo0jWVmM9yE9KY8=
github.com/kataras/pio v0.0.8/go.mod h1:NFfMp2kVP1rmV4N6gH6qgWpuoDKlrOeYi3VrAIWCGsE=
github.com/opentracing/opentracing-go v1.1.0 h1:pWlfV3Bxv7k65HYwkikxat0+s3pV4bsqf19k25Ur8rU=
github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2 h1:VklqNMn3ovrHsnt90PveolxSbWFaJdECFbxSq0Mqo2M=
Expand Down

0 comments on commit ab9d528

Please sign in to comment.