add plugin system

This commit is contained in:
ginuerzh
2023-04-18 20:52:56 +08:00
parent 7576651a67
commit 32c8188351
48 changed files with 761 additions and 115 deletions

View File

@ -1,6 +1,7 @@
package udp
import (
"context"
"net"
"github.com/go-gost/core/bypass"
@ -57,7 +58,7 @@ func (r *Relay) Run() (err error) {
return err
}
if r.bypass != nil && r.bypass.Contains(raddr.String()) {
if r.bypass != nil && r.bypass.Contains(context.Background(), raddr.String()) {
if r.logger != nil {
r.logger.Warn("bypass: ", raddr)
}
@ -95,7 +96,7 @@ func (r *Relay) Run() (err error) {
return err
}
if r.bypass != nil && r.bypass.Contains(raddr.String()) {
if r.bypass != nil && r.bypass.Contains(context.Background(), raddr.String()) {
if r.logger != nil {
r.logger.Warn("bypass: ", raddr)
}

View File

@ -1,6 +1,7 @@
package ssh
import (
"context"
"errors"
"fmt"
"io/ioutil"
@ -26,7 +27,7 @@ func PasswordCallback(au auth.Authenticator) PasswordCallbackFunc {
return nil
}
return func(conn ssh.ConnMetadata, password []byte) (*ssh.Permissions, error) {
if au.Authenticate(conn.User(), string(password)) {
if au.Authenticate(context.Background(), conn.User(), string(password)) {
return nil, nil
}
return nil, fmt.Errorf("password rejected for %s", conn.User())