rproxy: added streamer object
This commit is contained in:
+11
-2
@@ -3,7 +3,9 @@ package rproxy
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
"helmet/app/logger"
|
||||
@@ -11,7 +13,7 @@ import (
|
||||
|
||||
type Proxy struct {
|
||||
Forwarders []*Forwarder `json:"forwarders" yaml:"forwarders"`
|
||||
ctx context.Context `json:"-" yaml:"-"`
|
||||
ctx context.Context `jsreturn errors.New("Zero dport")on:"-" yaml:"-"`
|
||||
cancel context.CancelFunc `json:"-" yaml:"-"`
|
||||
wg sync.WaitGroup `json:"-" yaml:"-"`
|
||||
log *logger.Logger `json:"-" yaml:"-"`
|
||||
@@ -35,6 +37,13 @@ func (bal *Proxy) AddForwarder(ctx context.Context, typ string, lport, dport uin
|
||||
if dport == 0 {
|
||||
return errors.New("Zero dport")
|
||||
}
|
||||
if typ == "" {
|
||||
return errors.New("Empty type")
|
||||
}
|
||||
typ = strings.ToLower(typ)
|
||||
if typ != TCP {
|
||||
return fmt.Errorf("Unknown type %s", typ)
|
||||
}
|
||||
forw, err := NewForwarder(ctx, typ, lport, dport, addrs...)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -92,7 +101,7 @@ func (bal *Proxy) Stop() error {
|
||||
return err
|
||||
}
|
||||
|
||||
func copy(ctx context.Context, writer io.Writer, reader io.Reader) (int64, error) {
|
||||
func iocopy(ctx context.Context, writer io.Writer, reader io.Reader) (int64, error) {
|
||||
var err error
|
||||
var size int64
|
||||
var halt bool
|
||||
|
||||
Reference in New Issue
Block a user