util

package
v0.0.0-...-35ebf5e Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2024 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// 重试连接
	DisconnectActionRetry = iota
	// 重启程序
	DisconnectActionRestart
)

断连行为

Variables

View Source
var CLI struct {
	Dhcp       struct{} `cmd:"" help:"Use DHCP mode"`                                                    // DHCP模式
	DhcpAuto   struct{} `cmd:"" help:"Use DHCP mode with auto configuration"`                            // DHCP自动配置模式
	Pppoe      struct{} `cmd:"" help:"Use PPPoE mode"`                                                   // PPPoE模式
	Web        struct{} `cmd:"" help:"Imitate web login"`                                                // 模拟网页登录
	Conf       string   `help:"Configuration file path" short:"c" default:"/etc/drcom.conf" type:"path"` // 配置文件目录
	BindIP     string   `help:"IP address to bind to" short:"b" default:"0.0.0.0"`                       // 绑定IP地址
	Log        string   `help:"Log ONLY to specified path" short:"l" default:""`                         // 日志文件目录
	Daemon     bool     `help:"Run as daemon" short:"d" default:"false"`                                 // 是否在后台运行
	Eternal    bool     `help:"Keep trying to reconnect" short:"e" default:"false"`                      // 是否一直尝试重连
	Debug      bool     `help:"Print debug level logging" short:"D" default:"false"`                     // 是否打印调试信息
	AutoLogout bool     `help:"Logout (shut the connection) when exiting" short:"L" default:"false"`     // 是否在退出时注销
}
View Source
var ExtConf struct {
	// 检查连接(204)使用的 URL
	ConnectionTestServer string
	// 检查连接使用的 DNS
	DnsServer string
	// 断连行为
	ActionOnDisconnect int
	// 连接成功后执行的外部命令
	ExecOnConnect string
	// 连接失败后执行的外部命令
	ExecOnDisconnect string
}

drcom-go 专有扩展配置

View Source
var Logger *zap.Logger

Functions

func CheckConnection

func CheckConnection(ch chan bool, interval time.Duration)

CheckConnection 检查网络连接,如发现不通,向 ch 中发送信号

func Checksum

func Checksum(s []byte) []byte

进行 CRC 加密

来自于 drcom-generic 的 checksum 函数

func Daemonize

func Daemonize()

使程序在后台运行

func HookConnectSuccess

func HookConnectSuccess()

连接成功后执行的外部动作

func HookDisconnect

func HookDisconnect(failureCount int)

连接失败后执行的外部动作

failureCount: 失败次数

func ParseConf

func ParseConf()

解析配置文件

func Ror

func Ror(md5, pwd []byte) []byte

位移加密

来自于 drcom-generic 的 ror 函数

func SetupLog

func SetupLog()

初始化 logger

Types

type BaseConf

type BaseConf struct {
	Server             string
	Username           string
	Password           string
	ControlCheckStatus byte
	AdapterNum         byte
	HostIP             string
	IpDog              byte
	Hostname           string
	PrimaryDns         string
	DhcpServer         string
	AuthVersion        [2]byte
	Mac                string
	MacBytes           []byte
	HostOs             string
	KeepAliveVersion   [2]byte
	RorVersion         bool
}

对应 drcom-generic 配置

var Conf BaseConf

func (*BaseConf) SaveConf

func (c *BaseConf) SaveConf(path string)

生成配置文件

Jump to

Keyboard shortcuts

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