Documentation
¶
Index ¶
- Variables
- func FilterIpFromAddr(addr net.Addr) string
- func NewRealIP2_4() realIPv2_4
- func NewRealIP2_5(key *ecdsa.PrivateKey) realIPv2_5
- func ProxyConnection(client, server net.Conn)
- func Proxy_IOCopy(client, server net.Conn)
- type AlwaysAllowConnection
- type AlwaysOfflineState
- type AlwaysOnlineState
- type Backend
- type BackendAction
- type BackendAnswer
- type BackendConfig
- type BackendFactoryFunc
- type BackendManager
- type BackendRequest
- type BackendWorker
- func (w *BackendWorker) Close()
- func (worker *BackendWorker) HandleRequest(req BackendRequest) BackendAnswer
- func (w *BackendWorker) HasActiveConn() bool
- func (w *BackendWorker) ReqCh() chan<- BackendRequest
- func (w *BackendWorker) Run()
- func (w *BackendWorker) Update(cfg BackendConfig) error
- func (w *BackendWorker) UpdateSameGoroutine(wCfg BackendConfig)
- func (worker *BackendWorker) Work()
- type BasicWorker
- func (w *BasicWorker) CloseCh() chan<- struct{}
- func (w *BasicWorker) IODeadline() time.Time
- func (w *BasicWorker) KnowsDomain(domain string) bool
- func (bw *BasicWorker) NotSafeYet_ProcessConnection(conn net.Conn) (BackendRequest, error)
- func (bw *BasicWorker) ProcessAnswer(conn net.Conn, ans BackendAnswer)
- func (bw *BasicWorker) ProcessConnection(conn net.Conn) (BackendRequest, error)
- func (bw *BasicWorker) ProcessRequest(req BackendRequest) BackendAnswer
- func (w *BasicWorker) SetServers(servers map[string]chan<- BackendRequest)
- func (w *BasicWorker) Update(data map[string]chan<- BackendRequest)
- func (bw *BasicWorker) Work()
- type CheckOpenConns
- type ConnectionCreator
- type ConnectionCreatorFunc
- type ConnectionLimiter
- type HandshakeModifier
- type McServerState
- type ProxyAction
- type ServerState
- type StateAgent
- type StatusCache
- type UpdatableWorker
- type WorkerManager
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrNotValidHandshake = errors.New("not a valid handshake state") ErrClientToSlow = errors.New("client was to slow with sending its packets") ErrClientClosedConn = errors.New("client closed the connection") )
View Source
var ErrOverConnRateLimit = errors.New("too many request within rate limit time frame")
View Source
var ErrSameConfig = errors.New("old and new config are the same")
View Source
var ErrStatusPing = errors.New("something went wrong while pinging")
Functions ¶
func FilterIpFromAddr ¶
func NewRealIP2_4 ¶
func NewRealIP2_4() realIPv2_4
func NewRealIP2_5 ¶
func NewRealIP2_5(key *ecdsa.PrivateKey) realIPv2_5
func ProxyConnection ¶
TODO: - check or servers close the connection when they disconnect players if not add something to prevent abuse
func Proxy_IOCopy ¶
Types ¶
type AlwaysAllowConnection ¶
type AlwaysAllowConnection struct{}
func (AlwaysAllowConnection) Allow ¶
func (limiter AlwaysAllowConnection) Allow(req BackendRequest) (BackendAnswer, bool)
type AlwaysOfflineState ¶
type AlwaysOfflineState struct{}
func (AlwaysOfflineState) State ¶
func (agent AlwaysOfflineState) State() ServerState
type AlwaysOnlineState ¶
type AlwaysOnlineState struct{}
func (AlwaysOnlineState) State ¶
func (agent AlwaysOnlineState) State() ServerState
type Backend ¶
type Backend interface {
ReqCh() chan<- BackendRequest
HasActiveConn() bool
Update(cfg BackendConfig) error
Close()
}
type BackendAction ¶
type BackendAction byte
const ( Error BackendAction = iota Proxy Disconnect SendStatus Close )
func (BackendAction) String ¶
func (i BackendAction) String() string
type BackendAnswer ¶
type BackendAnswer struct {
ServerName string
// contains filtered or unexported fields
}
func NewCloseAnswer ¶
func NewCloseAnswer() BackendAnswer
func NewDisconnectAnswer ¶
func NewDisconnectAnswer(p mc.Packet) BackendAnswer
func NewProxyAnswer ¶
func NewProxyAnswer(p1, p2 mc.Packet, proxyCh chan ProxyAction, connFunc func() (net.Conn, error)) BackendAnswer
func NewStatusAnswer ¶
func NewStatusAnswer(p mc.Packet) BackendAnswer
func (BackendAnswer) Action ¶
func (ans BackendAnswer) Action() BackendAction
func (BackendAnswer) ProxyCh ¶
func (ans BackendAnswer) ProxyCh() chan ProxyAction
func (BackendAnswer) Response ¶
func (ans BackendAnswer) Response() mc.Packet
func (BackendAnswer) Response2 ¶
func (ans BackendAnswer) Response2() mc.Packet
func (BackendAnswer) ServerConn ¶
func (ans BackendAnswer) ServerConn() (net.Conn, error)
type BackendConfig ¶
type BackendConfig struct {
Name string
UpdateProxyProtocol bool
SendProxyProtocol bool
DisconnectPacket mc.Packet
OfflineStatusPacket mc.Packet
HsModifier HandshakeModifier
ConnCreator ConnectionCreator
ConnLimiter ConnectionLimiter
ServerState StateAgent
StatusCache StatusCache
}
func NewBackendConfig ¶
func NewBackendConfig(cfg config.BackendWorkerConfig) BackendConfig
type BackendFactoryFunc ¶
type BackendFactoryFunc func(config.BackendWorkerConfig) Backend
var BackendFactory BackendFactoryFunc = func(cfg config.BackendWorkerConfig) Backend { backendWorker := NewBackendWorker(cfg) backendWorker.Run() return &backendWorker }
type BackendManager ¶
type BackendManager struct {
// contains filtered or unexported fields
}
func NewBackendManager ¶
func NewBackendManager(manager WorkerManager, factory BackendFactoryFunc, cfgReader config.ServerConfigReader) BackendManager
func (*BackendManager) CheckActiveConnections ¶
func (manager *BackendManager) CheckActiveConnections() bool
func (*BackendManager) Update ¶
func (manager *BackendManager) Update() error
type BackendRequest ¶
type BackendRequest struct {
Type mc.HandshakeState
Handshake mc.ServerBoundHandshake
ServerAddr string
Addr net.Addr
Username string
Ch chan<- BackendAnswer
}
type BackendWorker ¶
type BackendWorker struct {
Name string
SendProxyProtocol bool
OfflineStatusPacket mc.Packet
DisconnectPacket mc.Packet
HsModifier HandshakeModifier
ConnCreator ConnectionCreator
ConnLimiter ConnectionLimiter
ServerState StateAgent
StatusCache StatusCache
// contains filtered or unexported fields
}
func NewBackendWorker ¶
func NewBackendWorker(cfgServer config.BackendWorkerConfig) BackendWorker
func NewEmptyBackendWorker ¶
func NewEmptyBackendWorker() BackendWorker
func (*BackendWorker) Close ¶
func (w *BackendWorker) Close()
func (*BackendWorker) HandleRequest ¶
func (worker *BackendWorker) HandleRequest(req BackendRequest) BackendAnswer
func (*BackendWorker) HasActiveConn ¶
func (w *BackendWorker) HasActiveConn() bool
func (*BackendWorker) ReqCh ¶
func (w *BackendWorker) ReqCh() chan<- BackendRequest
func (*BackendWorker) Run ¶
func (w *BackendWorker) Run()
func (*BackendWorker) Update ¶
func (w *BackendWorker) Update(cfg BackendConfig) error
func (*BackendWorker) UpdateSameGoroutine ¶
func (w *BackendWorker) UpdateSameGoroutine(wCfg BackendConfig)
TODO: Need different name for this...?
func (*BackendWorker) Work ¶
func (worker *BackendWorker) Work()
type BasicWorker ¶
type BasicWorker struct {
// contains filtered or unexported fields
}
func NewWorker ¶
func NewWorker(cfg config.WorkerConfig, reqCh <-chan net.Conn) BasicWorker
func (*BasicWorker) CloseCh ¶
func (w *BasicWorker) CloseCh() chan<- struct{}
func (*BasicWorker) IODeadline ¶
func (w *BasicWorker) IODeadline() time.Time
func (*BasicWorker) KnowsDomain ¶
func (w *BasicWorker) KnowsDomain(domain string) bool
func (*BasicWorker) NotSafeYet_ProcessConnection ¶
func (bw *BasicWorker) NotSafeYet_ProcessConnection(conn net.Conn) (BackendRequest, error)
func (*BasicWorker) ProcessAnswer ¶
func (bw *BasicWorker) ProcessAnswer(conn net.Conn, ans BackendAnswer)
TODO: - figure out or this need more deadlines
func (*BasicWorker) ProcessConnection ¶
func (bw *BasicWorker) ProcessConnection(conn net.Conn) (BackendRequest, error)
TODO: - Adding some more error tests
func (*BasicWorker) ProcessRequest ¶
func (bw *BasicWorker) ProcessRequest(req BackendRequest) BackendAnswer
func (*BasicWorker) SetServers ¶
func (w *BasicWorker) SetServers(servers map[string]chan<- BackendRequest)
func (*BasicWorker) Update ¶
func (w *BasicWorker) Update(data map[string]chan<- BackendRequest)
type CheckOpenConns ¶
type CheckOpenConns struct {
Ch chan bool
}
type ConnectionCreator ¶
type ConnectionCreatorFunc ¶
func BasicConnCreator ¶
func BasicConnCreator(proxyTo string, dialer net.Dialer) ConnectionCreatorFunc
type ConnectionLimiter ¶
type ConnectionLimiter interface {
// The process answer is empty and should be ignored when it does allow the connection to happen
// Returns true if the connection is allowed to happen
Allow(req BackendRequest) (BackendAnswer, bool)
}
func NewAbsConnLimiter ¶
func NewAbsConnLimiter(ratelimit int, cooldown time.Duration, limitStatus bool) ConnectionLimiter
func NewBotFilterConnLimiter ¶
type HandshakeModifier ¶
type HandshakeModifier interface {
Modify(hs *mc.ServerBoundHandshake, addr string)
}
type McServerState ¶
type McServerState struct {
// contains filtered or unexported fields
}
func (*McServerState) State ¶
func (server *McServerState) State() ServerState
type ProxyAction ¶
type ProxyAction int8
const ( ProxyOpen ProxyAction = iota ProxyClose )
func (ProxyAction) String ¶
func (i ProxyAction) String() string
type ServerState ¶
type ServerState byte
const ( Unknown ServerState = iota Online Offline )
func (ServerState) String ¶
func (i ServerState) String() string
type StateAgent ¶
type StateAgent interface {
State() ServerState
}
func NewMcServerState ¶
func NewMcServerState(cooldown time.Duration, connCreator ConnectionCreator) StateAgent
type StatusCache ¶
type StatusCache interface {
Status() (BackendAnswer, error)
}
func NewStatusCache ¶
func NewStatusCache(protocol int, cooldown time.Duration, connCreator ConnectionCreator) StatusCache
type UpdatableWorker ¶
type UpdatableWorker interface {
Update(data map[string]chan<- BackendRequest)
}
type WorkerManager ¶
type WorkerManager interface {
AddBackend(domains []string, ch chan<- BackendRequest)
RemoveBackend(domains []string)
KnowsDomain(domain string) bool
Register(worker UpdatableWorker, update bool)
}
func NewWorkerManager ¶
func NewWorkerManager(cfg config.UltravioletConfig, reqCh <-chan net.Conn) WorkerManager
Click to show internal directories.
Click to hide internal directories.