Documentation
¶
Overview ¶
*
- SpecterGO Copyright (C) 2018 SpecterTeam *
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version. *
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details. *
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
*
- SpecterGO Copyright (C) 2018 SpecterTeam *
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version. *
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details. *
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
*
- SpecterGO Copyright (C) 2018 SpecterTeam *
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version. *
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details. *
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
*
- SpecterGO Copyright (C) 2018 SpecterTeam *
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version. *
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details. *
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
Index ¶
- Constants
- type Expire
- type Handler
- type Handlers
- type Server
- func (s *Server) Cancel() context.CancelFunc
- func (ser *Server) CloseSession(addr *net.UDPAddr, reason string) error
- func (ser *Server) CloseSessionGUID(guid int64, reason string) error
- func (ser *Server) Count() int
- func (ser *Server) GetSession(addr *net.UDPAddr) (*Session, bool)
- func (ser *Server) GetSessionGUID(guid int64) (*Session, bool)
- func (ser *Server) HasBlockedAddress(ip net.IP) bool
- func (ser *Server) HasSession(addr net.Addr) bool
- func (ser *Server) HasSessionGUID(guid int64) bool
- func (ser *Server) IsClosed() bool
- func (ser *Server) IsRunning() bool
- func (ser *Server) ListenAndServe(ctx context.Context, addr *net.UDPAddr) error
- func (ser *Server) RangeSessions(f func(key string, value *Session) bool) error
- func (ser *Server) RemoveBlockedAddress(ip net.IP)
- func (ser *Server) SendPacket(addr *net.UDPAddr, pk raknet.Packet)
- func (ser *Server) SendRawPacket(addr *net.UDPAddr, b []byte)
- func (ser *Server) Serve(ctx context.Context, l *net.UDPConn) error
- func (ser *Server) SetBlockedAddress(ip net.IP, exp Expire)
- func (s *Server) SetCancel(cancel context.CancelFunc)
- func (s *Server) Shutdown()
- func (ser *Server) Start(ip string, port int)
- func (ser *Server) State() ServerState
- type ServerState
- type Session
- type SessionState
Constants ¶
View Source
const (
PermanentExpire = -1
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Expire ¶
func (*Expire) IsPermanent ¶
type Handler ¶
type Handler interface {
// StartServer is called on the server is started
StartServer()
// CloseServer is called on the server is closed
CloseServer()
// HandlePing is called on a ping packet is received
HandlePing(addr net.Addr)
// OpenPreConn is called before a new session is created
OpenPreConn(addr net.Addr)
// OpenConn is called on a new session is created
OpenConn(uid int64, addr net.Addr)
// ClosePreConn is called before a session is closed
ClosePreConn(uid int64)
// CloseConn is called on a session is closed
CloseConn(uid int64)
// HandleSendPacket handles a packet sent from the server to a client
HandleSendPacket(addr net.Addr, pk raknet.Packet)
// HandleRawPacket handles a raw packet no processed in Raknet server
HandleRawPacket(addr net.Addr, pk raknet.Packet)
// HandlePacket handles a message packet
HandlePacket(uid int64, pk raknet.Packet)
// HandleUnknownPacket handles a unknown packet
HandleUnknownPacket(uid int64, pk raknet.Packet)
}
Handler handles packets, connections and more from Raknet server
type Server ¶
type Server struct {
Logger *utils.Logger
Handlers Handlers
MaxConnections int
MTU int
Identifier identifier.Minecraft
UUID uuid.UUID
// BroadcastingEnabled broadcast the server for the outside
// if it enabled, the server send UnconnectedPong when received UnconnectPing.
BroadcastingEnabled bool
// contains filtered or unexported fields
}
func (*Server) Cancel ¶
func (s *Server) Cancel() context.CancelFunc
func (*Server) CloseSession ¶
func (*Server) CloseSessionGUID ¶
func (*Server) HasSessionGUID ¶
func (*Server) ListenAndServe ¶
func (*Server) RangeSessions ¶
RangeSessions processes for the sessions instead of "for range". if f returns false, stops the loop.
key is string(returned net.Addr.String()), value is *Session returns errors if key and value is invalid.
func (*Server) RemoveBlockedAddress ¶
func (*Server) SetCancel ¶
func (s *Server) SetCancel(cancel context.CancelFunc)
func (*Server) State ¶
func (ser *Server) State() ServerState
type ServerState ¶
type ServerState int
ServerState is a server state
const ( StateNew ServerState = iota StateRunning StateClosed )
type Session ¶
type Session struct {
Addr *net.UDPAddr
Conn *net.UDPConn
Logger *utils.Logger
Server *Server
GUID int64
MTU int
LatencyEnabled bool
LatencyIdentifier int64
State SessionState
// contains filtered or unexported fields
}
Session
func (*Session) SendPacket ¶
func (*Session) SendRawPacket ¶
func (*Session) SystemAddress ¶
func (session *Session) SystemAddress() *raknet.SystemAddress
type SessionState ¶
type SessionState int
const ( StateDisconected SessionState = iota StateHandshaking StateConnected )
Click to show internal directories.
Click to hide internal directories.