ac

package
v0.4.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 11, 2025 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxConcurrentConnection      = 256
	DefaultConnectionTimeoutMs   = 300 * 1000 // 300 seconds to delete idle connection, align with server
	PacketQueueSizePerConnection = 32

	ReportToServerInterval         = 60 // seconds
	MinialServerDiscoveryInterval  = 5  // seconds
	ServerKeepaliveInterval        = 20 // seconds
	ServerDiscoveryRetryBeforeFail = 3

	TokenStoreRefreshInterval = 10
	TempPortOpenTime          = 30 //

	IPSET_DEFAULT_NAME      = "defaultset"
	IPSET_DEFAULT_DOWN_NAME = "defaultset_down"
)
View Source
const (
	PASS_KNOCK_IP = iota
	PASS_KNOCKIP_WITH_RANGE
	PASS_PRE_ACCESS_IP
)

IP pass mode

Variables

View Source
var (
	ExeDirPath string
)

Functions

This section is empty.

Types

type AccessEntry added in v0.4.1

type AccessEntry struct {
	User       *common.AgentUser
	SrcAddrs   []*common.NetAddress
	DstAddrs   []*common.NetAddress
	OpenTime   int
	ExpireTime time.Time
}

type Config

type Config struct {
	PrivateKeyBase64    string          `json:"privateKey"`
	ACId                string          `json:"acId"`
	DefaultIp           string          `json:"defaultIp"`
	AuthServiceId       string          `json:"aspId"`
	ResourceIds         []string        `json:"resIds"`
	Servers             []*core.UdpPeer `json:"servers"`
	IpPassMode          int             `json:"ipPassMode"` // 0: pass the knock source IP, 1: use pre-access mode and release the access source IP
	LogLevel            int             `json:"logLevel"`
	DefaultCipherScheme int             `json:"defaultCipherScheme"`
}

type HttpAC added in v0.4.1

type HttpAC struct {
	// contains filtered or unexported fields
}

func (*HttpAC) HandleHttpRefreshOperations added in v0.4.1

func (ha *HttpAC) HandleHttpRefreshOperations(c *gin.Context, req *common.HttpRefreshRequest)

func (*HttpAC) IsRunning added in v0.4.1

func (hs *HttpAC) IsRunning() bool

func (*HttpAC) Start added in v0.4.1

func (hs *HttpAC) Start(uac *UdpAC, hc *HttpConfig) error

Note HttpServer must be started after starting UdpAC, when log and config have been setup

func (*HttpAC) Stop added in v0.4.1

func (hs *HttpAC) 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 HttpConfig added in v0.4.1

type HttpConfig struct {
	EnableHttp     bool
	EnableTLS      bool
	HttpListenPort int
	TLSCertFile    string
	TLSKeyFile     string
}

type Peers

type Peers struct {
	Servers []*core.UdpPeer
}

type TokenStore added in v0.4.1

type TokenStore = map[string]TokenToAccessMap // upper layer of tokens, indexed by first two characters

type TokenToAccessMap added in v0.4.1

type TokenToAccessMap = map[string]*AccessEntry // access token mapped into user and access information

type UdpAC added in v0.4.0

type UdpAC struct {
	// contains filtered or unexported fields
}

func (*UdpAC) AddServerPeer added in v0.4.0

func (a *UdpAC) AddServerPeer(server *core.UdpPeer)

func (*UdpAC) GenerateAccessToken added in v0.4.0

func (a *UdpAC) GenerateAccessToken(entry *AccessEntry) string

func (*UdpAC) HandleAccessControl added in v0.4.1

func (a *UdpAC) HandleAccessControl(au *common.AgentUser, srcAddrs []*common.NetAddress, dstAddrs []*common.NetAddress, openTimeSec int, artMsgIn *common.ACOpsResultMsg) (artMsg *common.ACOpsResultMsg, err error)

func (*UdpAC) HandleUdpACOperations added in v0.4.1

func (a *UdpAC) HandleUdpACOperations(ppd *core.PacketParserData) (err error)

func (*UdpAC) IpPassMode added in v0.4.0

func (a *UdpAC) IpPassMode() int

func (*UdpAC) IsRunning added in v0.4.0

func (a *UdpAC) IsRunning() bool

func (*UdpAC) RemoveServerPeer added in v0.4.0

func (a *UdpAC) RemoveServerPeer(serverKey string)

func (*UdpAC) ResolvePeer added in v0.4.0

func (a *UdpAC) ResolvePeer(peer *core.UdpPeer) (*core.UdpPeer, net.Addr)

if the server uses hostname as destination, find the correct peer with the actual IP address

func (*UdpAC) SendPacket added in v0.4.0

func (a *UdpAC) SendPacket(pkt *core.Packet, conn *UdpConn) (n int, err error)

func (*UdpAC) Start added in v0.4.0

func (a *UdpAC) Start(dirPath string, logLevel int) (err error)

dirPath: the path of app or shared library entry point logLevel: 0: silent, 1: error, 2: info, 3: debug, 4: verbose

func (*UdpAC) Stop added in v0.4.0

func (ac *UdpAC) Stop()

func (*UdpAC) StopConfigWatch added in v0.4.0

func (a *UdpAC) StopConfigWatch()

func (*UdpAC) VerifyAccessToken added in v0.4.0

func (a *UdpAC) VerifyAccessToken(token string) *AccessEntry

type UdpConn

type UdpConn struct {
	ConnData *core.ConnectionData
	// contains filtered or unexported fields
}

func (*UdpConn) Close

func (c *UdpConn) Close()

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL