Skip to content

Commit

Permalink
fixed typo allways > always
Browse files Browse the repository at this point in the history
  • Loading branch information
nightshift2k committed Oct 14, 2021
1 parent 7fb212e commit 0faef4f
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 25 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ Application Options:
-c, --disable-fake-candles Disable generation of fake candles (ohlcv) when sockets have not delivered data yet [$BPX_DISABLE_FAKE_CANDLES]
-s, --disable-spot Disable proxying spot markets [$BPX_DISABLE_SPOT]
-f, --disable-futures Disable proxying futures markets [$BPX_DISABLE_FUTURES]
-a, --allways-show-forwards Allways show requests forwarded via REST even if verbose is disabled [$BPX_ALLWAYS_SHOW_FORWARDS]
-a, --always-show-forwards Always show requests forwarded via REST even if verbose is disabled [$BPX_ALWAYS_SHOW_FORWARDS]
Help Options:
-h, --help Show this help message
Expand Down Expand Up @@ -108,7 +108,7 @@ binance-proxy [OPTION]
| `-c` | Disables the generation of fake candles, when not yet recieved through websockets. | `bool` | `false` | No |
| `-s` | Disables proxy for **SPOT** markets. | `bool` | `false` | No |
| `-f` | Disables proxy for **FUTURES** markets. | `bool` | `false` | No |
| `-a` | Allways show requests forwarded via REST even if verbose is disabled | `bool` | `false` | No |
| `-a` | Always show requests forwarded via REST even if verbose is disabled | `bool` | `false` | No |

## 🐞 Bug / Feature Request

Expand Down
26 changes: 13 additions & 13 deletions cmd/binance-proxy/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ import (
log "github.com/sirupsen/logrus"
)

func startProxy(ctx context.Context, port int, class service.Class, disablefakekline bool, allwaysshowforwards bool) {
func startProxy(ctx context.Context, port int, class service.Class, disablefakekline bool, alwaysshowforwards bool) {
mux := http.NewServeMux()
address := fmt.Sprintf(":%d", port)
mux.HandleFunc("/", handler.NewHandler(ctx, class, !disablefakekline, allwaysshowforwards))
mux.HandleFunc("/", handler.NewHandler(ctx, class, !disablefakekline, alwaysshowforwards))

log.Infof("%s websocket proxy starting on port %d.", class, port)
if err := http.ListenAndServe(address, mux); err != nil {
Expand All @@ -39,13 +39,13 @@ func handleSignal() {
}

type Config struct {
Verbose []bool `short:"v" long:"verbose" env:"BPX_VERBOSE" description:"Verbose output (increase with -vv)"`
SpotAddress int `short:"p" long:"port-spot" env:"BPX_PORT_SPOT" description:"Port to which to bind for SPOT markets" default:"8090"`
FuturesAddress int `short:"t" long:"port-futures" env:"BPX_PORT_FUTURES" description:"Port to which to bind for FUTURES markets" default:"8091"`
DisableFakeKline bool `short:"c" long:"disable-fake-candles" env:"BPX_DISABLE_FAKE_CANDLES" description:"Disable generation of fake candles (ohlcv) when sockets have not delivered data yet"`
DisableSpot bool `short:"s" long:"disable-spot" env:"BPX_DISABLE_SPOT" description:"Disable proxying spot markets"`
DisableFutures bool `short:"f" long:"disable-futures" env:"BPX_DISABLE_FUTURES" description:"Disable proxying futures markets"`
AllwaysShowForwards bool `short:"a" long:"allways-show-forwards" env:"BPX_ALLWAYS_SHOW_FORWARDS" description:"Allways show requests forwarded via REST even if verbose is disabled"`
Verbose []bool `short:"v" long:"verbose" env:"BPX_VERBOSE" description:"Verbose output (increase with -vv)"`
SpotAddress int `short:"p" long:"port-spot" env:"BPX_PORT_SPOT" description:"Port to which to bind for SPOT markets" default:"8090"`
FuturesAddress int `short:"t" long:"port-futures" env:"BPX_PORT_FUTURES" description:"Port to which to bind for FUTURES markets" default:"8091"`
DisableFakeKline bool `short:"c" long:"disable-fake-candles" env:"BPX_DISABLE_FAKE_CANDLES" description:"Disable generation of fake candles (ohlcv) when sockets have not delivered data yet"`
DisableSpot bool `short:"s" long:"disable-spot" env:"BPX_DISABLE_SPOT" description:"Disable proxying spot markets"`
DisableFutures bool `short:"f" long:"disable-futures" env:"BPX_DISABLE_FUTURES" description:"Disable proxying futures markets"`
AlwaysShowForwards bool `short:"a" long:"always-show-forwards" env:"BPX_ALWAYS_SHOW_FORWARDS" description:"Always show requests forwarded via REST even if verbose is disabled"`
}

var (
Expand Down Expand Up @@ -92,17 +92,17 @@ func main() {
log.Infof("Fake candles are enabled for faster processing, the feature can be disabled with --disable-fake-candles or -c")
}

if config.AllwaysShowForwards {
log.Infof("Allways show forwards is enabled, all API requests, that can't be served from websockets cached will be logged.")
if config.AlwaysShowForwards {
log.Infof("Always show forwards is enabled, all API requests, that can't be served from websockets cached will be logged.")
}

go handleSignal()

if !config.DisableSpot {
go startProxy(ctx, config.SpotAddress, service.SPOT, config.DisableFakeKline, config.AllwaysShowForwards)
go startProxy(ctx, config.SpotAddress, service.SPOT, config.DisableFakeKline, config.AlwaysShowForwards)
}
if !config.DisableFutures {
go startProxy(ctx, config.FuturesAddress, service.FUTURES, config.DisableFakeKline, config.AllwaysShowForwards)
go startProxy(ctx, config.FuturesAddress, service.FUTURES, config.DisableFakeKline, config.AlwaysShowForwards)
}
<-ctx.Done()

Expand Down
20 changes: 10 additions & 10 deletions internal/handler/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ import (
log "github.com/sirupsen/logrus"
)

func NewHandler(ctx context.Context, class service.Class, enableFakeKline bool, allwaysShowForwards bool) func(w http.ResponseWriter, r *http.Request) {
func NewHandler(ctx context.Context, class service.Class, enableFakeKline bool, alwaysShowForwards bool) func(w http.ResponseWriter, r *http.Request) {
handler := &Handler{
srv: service.NewService(ctx, class),
class: class,
enableFakeKline: enableFakeKline,
allwaysShowForwards: allwaysShowForwards,
srv: service.NewService(ctx, class),
class: class,
enableFakeKline: enableFakeKline,
alwaysShowForwards: alwaysShowForwards,
}
handler.ctx, handler.cancel = context.WithCancel(ctx)

Expand All @@ -28,10 +28,10 @@ type Handler struct {
ctx context.Context
cancel context.CancelFunc

class service.Class
srv *service.Service
enableFakeKline bool
allwaysShowForwards bool
class service.Class
srv *service.Service
enableFakeKline bool
alwaysShowForwards bool
}

func (s *Handler) Router(w http.ResponseWriter, r *http.Request) {
Expand Down Expand Up @@ -59,7 +59,7 @@ func (s *Handler) Router(w http.ResponseWriter, r *http.Request) {

func (s *Handler) reverseProxy(w http.ResponseWriter, r *http.Request) {
msg := fmt.Sprintf("%s request %s %s from %s is not cachable", s.class, r.Method, r.RequestURI, r.RemoteAddr)
if s.allwaysShowForwards {
if s.alwaysShowForwards {
log.Infof(msg)
} else {
log.Tracef(msg)
Expand Down

0 comments on commit 0faef4f

Please sign in to comment.