Documentation ¶
Index ¶
- Constants
- Variables
- func LoadFilesRecursively(g *gin.Engine, dir string)
- type ACConn
- type BlockAddr
- type Config
- type HttpConfig
- type HttpServer
- type Peers
- type UdpConn
- type UdpServer
- func (s *UdpServer) AddACPeer(acPeer *core.UdpPeer)
- func (s *UdpServer) AddAddressAssociation(srcIp string, addrs []*common.NetAddress)
- func (s *UdpServer) AddAgentPeer(agent *core.UdpPeer)
- func (s *UdpServer) AddAuthService(aspData *common.AuthServiceProviderData) error
- func (s *UdpServer) AddBlockAddr(addr *net.UDPAddr)
- func (s *UdpServer) AddResource(res *common.ResourceData) error
- func (s *UdpServer) BlockAddrRefreshRoutine()
- func (s *UdpServer) ClosePlugins()
- func (s *UdpServer) FindAuthSvcProvider(aspId string) *common.AuthServiceProviderData
- func (us *UdpServer) FindPluginHandler(aspId string) plugins.PluginHandler
- func (s *UdpServer) HandleACOnline(ppd *core.PacketParserData) (err error)
- func (s *UdpServer) HandleKnockRequest(ppd *core.PacketParserData) (err error)
- func (s *UdpServer) HandleListRequest(ppd *core.PacketParserData) (err error)
- func (s *UdpServer) HandleOTPRequest(ppd *core.PacketParserData) (err error)
- func (s *UdpServer) HandleRegisterRequest(ppd *core.PacketParserData) (err error)
- func (s *UdpServer) IsBlockAddr(addr *net.UDPAddr) bool
- func (s *UdpServer) IsRunning() bool
- func (s *UdpServer) LoadPlugin(pluginId string, h plugins.PluginHandler) error
- func (us *UdpServer) NewNhpServerHelper(ppd *core.PacketParserData) *plugins.NhpServerPluginHelper
- func (s *UdpServer) RefreshBlockAddr()
- func (s *UdpServer) RemoveAddressAssociation(srcIp string)
- func (s *UdpServer) SendPacket(pkt *core.Packet, conn *UdpConn) (n int, err error)
- func (s *UdpServer) Start(dirPath string, logLevel int) (err error)
- func (s *UdpServer) Stop()
- func (s *UdpServer) StopConfigWatch()
- func (s *UdpServer) ValidatePlugin(h plugins.PluginHandler) bool
Constants ¶
const ( MaxConcurrentConnection = 20480 OverloadConnectionThreshold = MaxConcurrentConnection * 4 / 5 // 80% BlockAddrRefreshRate = 20 // 20 seconds BlockAddrExpireTime = 90 // 90 seconds PreCheckThreatCountBeforeBlock = 5 // block source address if packet precheck errors exceeds this count DefaultAgentConnectionTimeoutMs = 30 * 1000 // 30 seconds to delete idle connection DefaultACConnectionTimeoutMs = 300 * 1000 // 300 seconds to delete idle connection PacketQueueSizePerConnection = 64 )
const ( DefaultIpOpenTime = 120 // second, align with ipset default timeout ACOpenCompensationTime = 5 // second )
knock
const (
HttpTransactionTimeout = 3 // second
)
http APIs
Variables ¶
var (
ExeDirPath string
)
Functions ¶
func LoadFilesRecursively ¶
LoadFilesRecursively loads HTML and template files recursively from the specified directory and adds them to the given gin.Engine. It walks through the directory and its subdirectories, and for each file with a .html or .tmpl extension, it reads the file content, creates a new template with the file path as the template name, and parses the content into the template. The loaded templates are set as the HTML templates for the gin.Engine. The directory path should be a clean absolute path. If any error occurs during the file loading or template parsing, the function returns the error.
Types ¶
type HttpConfig ¶
type HttpServer ¶
type HttpServer struct {
// contains filtered or unexported fields
}
func (*HttpServer) FindPluginHandler ¶
func (hs *HttpServer) FindPluginHandler(aspId string) plugins.PluginHandler
FindPluginHandler returns the plugin handler for the given ASP ID It delegates the task to the underlying UDP server's FindPluginHandler method.
func (*HttpServer) IsRunning ¶
func (hs *HttpServer) IsRunning() bool
func (*HttpServer) NewHttpServerHelper ¶
func (hs *HttpServer) NewHttpServerHelper() *plugins.HttpServerPluginHelper
func (*HttpServer) Start ¶
func (hs *HttpServer) Start(us *UdpServer, hc *HttpConfig) error
Note HttpServer must be started after starting UdpServer, when log and config have been setup
func (*HttpServer) Stop ¶
func (hs *HttpServer) Stop()
Stop stops the HttpServer by setting the running flag to false, closing the stop channel, shutting down the underlying http server, waiting for all goroutines to finish, and logging a message indicating that the HttpServer has been stopped.
type UdpConn ¶
type UdpConn struct { ConnData *core.ConnectionData // contains filtered or unexported fields }
type UdpServer ¶
type UdpServer struct {
// contains filtered or unexported fields
}
func (*UdpServer) AddAddressAssociation ¶
func (s *UdpServer) AddAddressAssociation(srcIp string, addrs []*common.NetAddress)
func (*UdpServer) AddAgentPeer ¶
func (*UdpServer) AddAuthService ¶
func (s *UdpServer) AddAuthService(aspData *common.AuthServiceProviderData) error
func (*UdpServer) AddBlockAddr ¶
func (*UdpServer) AddResource ¶
func (s *UdpServer) AddResource(res *common.ResourceData) error
func (*UdpServer) BlockAddrRefreshRoutine ¶
func (s *UdpServer) BlockAddrRefreshRoutine()
func (*UdpServer) ClosePlugins ¶
func (s *UdpServer) ClosePlugins()
func (*UdpServer) FindAuthSvcProvider ¶
func (s *UdpServer) FindAuthSvcProvider(aspId string) *common.AuthServiceProviderData
func (*UdpServer) FindPluginHandler ¶
func (us *UdpServer) FindPluginHandler(aspId string) plugins.PluginHandler
func (*UdpServer) HandleACOnline ¶
func (s *UdpServer) HandleACOnline(ppd *core.PacketParserData) (err error)
func (*UdpServer) HandleKnockRequest ¶
func (s *UdpServer) HandleKnockRequest(ppd *core.PacketParserData) (err error)
HandleKnockRequest Server will respond with success or error with NHP_ACK message
func (*UdpServer) HandleListRequest ¶
func (s *UdpServer) HandleListRequest(ppd *core.PacketParserData) (err error)
HandleListRequest Server will respond with success or error with NHP_LRT message
func (*UdpServer) HandleOTPRequest ¶
func (s *UdpServer) HandleOTPRequest(ppd *core.PacketParserData) (err error)
HandleOTPRequest Server will not respond to agent's otp request
func (*UdpServer) HandleRegisterRequest ¶
func (s *UdpServer) HandleRegisterRequest(ppd *core.PacketParserData) (err error)
HandleRegisterRequest Server will respond with success or error with NHP_RAK message
func (*UdpServer) LoadPlugin ¶
func (s *UdpServer) LoadPlugin(pluginId string, h plugins.PluginHandler) error
func (*UdpServer) NewNhpServerHelper ¶
func (us *UdpServer) NewNhpServerHelper(ppd *core.PacketParserData) *plugins.NhpServerPluginHelper
func (*UdpServer) RefreshBlockAddr ¶
func (s *UdpServer) RefreshBlockAddr()
func (*UdpServer) RemoveAddressAssociation ¶
func (*UdpServer) SendPacket ¶
func (*UdpServer) Start ¶
dirPath: the path of app or shared library entry point logLevel: 0: silent, 1: error, 2: info, 3: debug, 4: verbose
UDP server never actively sends first packet outwards. It only reacts to received packet then sends response.
func (*UdpServer) StopConfigWatch ¶
func (s *UdpServer) StopConfigWatch()
func (*UdpServer) ValidatePlugin ¶
func (s *UdpServer) ValidatePlugin(h plugins.PluginHandler) bool