core plugin

This commit is contained in:
刘河
2019-10-14 23:04:14 +08:00
parent 98ab48aaca
commit 8f45d86cee
6 changed files with 39 additions and 92 deletions

View File

@@ -8,6 +8,7 @@ import (
)
type Proxy struct {
core.NpsPlugin
clientConn net.Conn
ctx context.Context
}
@@ -15,20 +16,9 @@ type Proxy struct {
func (proxy *Proxy) GetConfigName() *core.NpsConfigs {
return core.NewNpsConfigs("socks5_proxy", "proxy to inet")
}
func (proxy *Proxy) GetStage() core.Stage {
return core.STAGE_RUN
}
func (proxy *Proxy) Start(ctx context.Context, config map[string]string) error {
return nil
}
func (proxy *Proxy) Run(ctx context.Context, config map[string]string) error {
clientCtxConn := ctx.Value(core.CLIENT_CONNECTION)
if clientCtxConn == nil {
return core.CLIENT_CONNECTION_NOT_EXIST
}
proxy.clientConn = clientCtxConn.(net.Conn)
proxy.clientConn = proxy.GetClientConn(ctx)
proxy.ctx = ctx
bg := ctx.Value(core.BRIDGE)
if bg == nil {
@@ -53,7 +43,3 @@ func (proxy *Proxy) Run(ctx context.Context, config map[string]string) error {
core.CopyBuffer(clientCtxConn.(net.Conn), severConn)
return nil
}
func (proxy *Proxy) End(ctx context.Context, config map[string]string) error {
return nil
}