Skip to content

Commit

Permalink
Refactor therealproxy
Browse files Browse the repository at this point in the history
  • Loading branch information
Darkren committed Oct 24, 2019
1 parent 829f638 commit f66ac59
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 12 deletions.
6 changes: 2 additions & 4 deletions cmd/apps/skychat/chat.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,12 @@ import (
"sync"
"time"

"github.com/skycoin/skywire/pkg/app2/appnet"

"github.com/skycoin/skywire/pkg/app2"

"github.com/skycoin/dmsg/cipher"
"github.com/skycoin/skycoin/src/util/logging"

"github.com/skycoin/skywire/internal/netutil"
"github.com/skycoin/skywire/pkg/app2"
"github.com/skycoin/skywire/pkg/app2/appnet"
"github.com/skycoin/skywire/pkg/routing"
)

Expand Down
35 changes: 27 additions & 8 deletions cmd/apps/therealproxy/therealproxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,33 +5,52 @@ package main

import (
"flag"
"fmt"

"github.com/skycoin/skycoin/src/util/logging"

"github.com/skycoin/skywire/internal/therealproxy"
"github.com/skycoin/skywire/pkg/app"
"github.com/skycoin/skywire/pkg/app2"
"github.com/skycoin/skywire/pkg/app2/appnet"
"github.com/skycoin/skywire/pkg/routing"
)

const (
netType = appnet.TypeDMSG
port = routing.Port(1024)
)

func main() {
log := app.NewLogger("socksproxy")
appName := "socksproxy"

log := app2.NewLogger(appName)
therealproxy.Log = log.PackageLogger("therealproxy")

var passcode = flag.String("passcode", "", "Authorize user against this passcode")
flag.Parse()

config := &app.Config{AppName: "socksproxy", AppVersion: "1.0", ProtocolVersion: "0.0.1"}
socksApp, err := app.Setup(config)
config, err := app2.ClientConfigFromEnv()
if err != nil {
log.Fatalf("Error getting client config: %v\n", err)
}

socksApp, err := app2.NewClient(logging.MustGetLogger(fmt.Sprintf("app_%s", appName)), config)
if err != nil {
log.Fatal("Setup failure: ", err)
}
defer func() {
if err := socksApp.Close(); err != nil {
log.Println("Failed to close app:", err)
}
socksApp.Close()
}()

srv, err := therealproxy.NewServer(*passcode, log)
if err != nil {
log.Fatal("Failed to create a new server: ", err)
}

log.Fatal(srv.Serve(socksApp))
l, err := socksApp.Listen(netType, port)
if err != nil {
log.Fatalf("Error listening network %v on port %d: %v\n", netType, port, err)
}

log.Fatal(srv.Serve(l))
}

0 comments on commit f66ac59

Please sign in to comment.