Documentation
¶
Overview ¶
Copyright 2022 gdy, 272288813@qq.com
Copyright 2022 gdy, 272288813@qq.com
Copyright 2022 gdy, 272288813@qq.com
Copyright 2022 gdy, 272288813@qq.com
Index ¶
- Variables
- func BlackListAdd(ip string, activelifeDuration int32) (string, error)
- func BlackListDelete(ip string) error
- func BlackListFlush(lock bool) error
- func BlackListInit()
- func CheckDDNSTaskAvalid(task *DDNSTask) error
- func CheckTCPPortAvalid(port int) bool
- func CreateReverseProxyLogbuffer(key string, buffSize int) *logsbuffer.LogsBuffer
- func DDNSTaskListAdd(task *DDNSTask) error
- func DDNSTaskListConfigureCheck()
- func DDNSTaskListDelete(taskKey string) error
- func DDNSTaskSetWebhookCallResult(taskKey string, result bool, message string)
- func EnableDDNSTaskByKey(taskKey string, enable bool) error
- func EnableReverseProxyRuleByKey(ruleKey string, enable bool) error
- func EnableReverseProxySubRule(ruleKey, proxyKey string, enable bool) error
- func FlushLoginRandomKey()
- func GetAuthAccount() map[string]string
- func GetConfigureBytes() []byte
- func GetLoginRandomKey() string
- func GetRunMode() string
- func GetVersion() string
- func InitAppInfo(version, date string)
- func LoadDefault(proxyCountLimit int64, adminWebListenPort int, globalMaxConnections int64)
- func Read(filePath string) (err error)
- func ReverseProxyLogConvert(lg *logsbuffer.LogItem) any
- func ReverseProxyRuleListAdd(rule *ReverseProxyRule) error
- func ReverseProxyRuleListDelete(ruleKey string) error
- func SafeCheck(mode, ip string) bool
- func Save() (err error)
- func SetBaseConfigure(conf *BaseConfigure) error
- func SetConfig(p *ProgramConfigure) error
- func SetConfigRuleList(ruleList *[]ConfigureRelayRule)
- func SetDDNSConfigure(conf *DDNSConfigure) error
- func SetRunMode(mode string)
- func SetVersion(v string)
- func SetWhiteListBaseConfigure(activelifeDuration int32, url, account, password string) error
- func TidyReverseProxyCache()
- func UpdateReverseProxyRulet(rule ReverseProxyRule) error
- func UpdateTaskToDDNSTaskList(taskKey string, task DDNSTask) error
- func WhiteListAdd(ip string, activelifeDuration int32) (string, error)
- func WhiteListDelete(ip string) error
- func WhiteListFlush(lock bool) error
- func WhiteListInit()
- type AppInfo
- type BaseConfigure
- type BlackListConfigure
- type BlackListItem
- type ConfigureRelayRule
- type DDNSConfigure
- type DDNSTask
- type DNSCallback
- type DNSConfig
- type LogItem
- type ProgramConfigure
- type ReverseProxy
- type ReverseProxyRule
- func (r *ReverseProxyRule) Addr() string
- func (r *ReverseProxyRule) GetLastLogs() map[string][]any
- func (r *ReverseProxyRule) GetServer() *http.Server
- func (r *ReverseProxyRule) GetSubRuleByDomain(domain string) (*ReverseProxy, bool)
- func (r *ReverseProxyRule) Init()
- func (r *ReverseProxyRule) ReverseProxyHandler(c *gin.Context)
- func (r *ReverseProxyRule) ServerStart() error
- func (r *ReverseProxyRule) ServerStop()
- func (r *ReverseProxyRule) SetServer(s *http.Server)
- type SubReverProxyRule
- func (r *SubReverProxyRule) BasicAuthHandler(c *gin.Context) bool
- func (r *SubReverProxyRule) ClientIP(c *gin.Context) string
- func (r *SubReverProxyRule) GetLocation() string
- func (r *SubReverProxyRule) GetLogger() *log.Logger
- func (r *SubReverProxyRule) GetLogrus() *logrus.Logger
- func (r *SubReverProxyRule) GetLogsBuffer() *logsbuffer.LogsBuffer
- func (r *SubReverProxyRule) HandlerReverseProxy(remote *url.URL, path string, c *gin.Context)
- func (r *SubReverProxyRule) InitTrustedProxyCIDRs() error
- func (r *SubReverProxyRule) Logf(level logrus.Level, c *gin.Context, format string, v ...any)
- func (r *SubReverProxyRule) PrintfToConsole(entry *logrus.Entry) error
- type Webhook
- type WhiteListBaseConfigure
- type WhiteListConfigure
- type WhiteListItem
Constants ¶
This section is empty.
Variables ¶
View Source
var DefaultIPv4DNSServerList = []string{
"1.1.1.1:53",
"1.2.4.8:53",
"8.8.8.8:53",
"9.9.9.9:53",
"8.8.4.4:53",
"114.114.114.114:53",
"223.5.5.5:53",
"223.6.6.6:53",
"101.226.4.6:53",
"218.30.118.6:53",
"119.28.28.28:53",
}
View Source
var DefaultIPv6DNSServerList = []string{
"[2001:4860:4860::8888]:53",
"[2001:4860:4860::8844]:53",
"[2606:4700:4700::64]:53",
"[2606:4700:4700::6400]:53",
"[240C::6666]:53",
"[240C::6644]:53",
"[2402:4e00::]:53",
"[240e:4c:4008::1]:53",
"[240e:4c:4808::1]:53",
"[2408:8899::8]:53",
"[2408:8888::8]:53",
"[2409:8088::a]:53",
"[2409:8088::b]:53",
"[2001:dc7:1000::1]:53",
"[2400:da00::6666]:53",
}
Functions ¶
func BlackListDelete ¶
func BlackListFlush ¶
func BlackListInit ¶ added in v1.3.1
func BlackListInit()
func CheckDDNSTaskAvalid ¶
func CheckTCPPortAvalid ¶
func CreateReverseProxyLogbuffer ¶ added in v1.3.1
func CreateReverseProxyLogbuffer(key string, buffSize int) *logsbuffer.LogsBuffer
func DDNSTaskListAdd ¶
func DDNSTaskListConfigureCheck ¶ added in v1.2.1
func DDNSTaskListConfigureCheck()
func DDNSTaskListDelete ¶
func EnableDDNSTaskByKey ¶
func EnableReverseProxyRuleByKey ¶ added in v1.3.1
func EnableReverseProxySubRule ¶ added in v1.3.1
func FlushLoginRandomKey ¶
func FlushLoginRandomKey()
func GetAuthAccount ¶
func GetConfigureBytes ¶ added in v1.1.8
func GetConfigureBytes() []byte
func GetLoginRandomKey ¶
func GetLoginRandomKey() string
func GetRunMode ¶
func GetRunMode() string
func GetVersion ¶
func GetVersion() string
func InitAppInfo ¶
func InitAppInfo(version, date string)
func LoadDefault ¶
func ReverseProxyLogConvert ¶ added in v1.3.1
func ReverseProxyLogConvert(lg *logsbuffer.LogItem) any
2006-01-02 15:04:05
func ReverseProxyRuleListAdd ¶ added in v1.3.1
func ReverseProxyRuleListAdd(rule *ReverseProxyRule) error
func ReverseProxyRuleListDelete ¶ added in v1.3.1
func SetConfig ¶ added in v1.1.8
func SetConfig(p *ProgramConfigure) error
func SetConfigRuleList ¶
func SetConfigRuleList(ruleList *[]ConfigureRelayRule)
func SetDDNSConfigure ¶
func SetDDNSConfigure(conf *DDNSConfigure) error
func SetRunMode ¶
func SetRunMode(mode string)
func SetVersion ¶
func SetVersion(v string)
func TidyReverseProxyCache ¶ added in v1.3.1
func TidyReverseProxyCache()
TidyReverseProxyCache 整理反向代理日志缓存
func UpdateReverseProxyRulet ¶ added in v1.3.1
func UpdateReverseProxyRulet(rule ReverseProxyRule) error
func WhiteListDelete ¶
func WhiteListFlush ¶
func WhiteListInit ¶ added in v1.3.1
func WhiteListInit()
Types ¶
type AppInfo ¶
type AppInfo struct { AppName string Version string OS string ARCH string Date string RunTime string GoVersion string }
func GetAppInfo ¶
func GetAppInfo() *AppInfo
type BaseConfigure ¶
type BaseConfigure struct { AdminWebListenPort int `json:"AdminWebListenPort"` //管理后台端口 ProxyCountLimit int64 `json:"ProxyCountLimit"` //全局代理数量限制 AdminAccount string `json:"AdminAccount"` //登录账号 AdminPassword string `json:"AdminPassword"` //登录密码 AllowInternetaccess bool `json:"AllowInternetaccess"` //允许外网访问 GlobalMaxConnections int64 `json:"GlobalMaxConnections"` //全局最大连接数 LogMaxSize int `json:"LogMaxSize"` //日志记录最大条数 }
func GetBaseConfigure ¶
func GetBaseConfigure() BaseConfigure
type BlackListConfigure ¶
type BlackListConfigure struct {
BlackList []BlackListItem `json:"BlackList"` //黑名单列表
}
type BlackListItem ¶
type BlackListItem WhiteListItem
func DeleteBlackListlice ¶
func DeleteBlackListlice(a []BlackListItem, deleteIndex int) []BlackListItem
func GetBlackList ¶
func GetBlackList() []BlackListItem
func (*BlackListItem) Contains ¶ added in v1.3.1
func (w *BlackListItem) Contains(ip string) bool
type ConfigureRelayRule ¶
type ConfigureRelayRule struct { Name string `json:"Name"` Configurestr string `json:"Configurestr"` Enable bool `json:"Enable"` Options socketproxy.RelayRuleOptions `json:"Options"` }
type DDNSConfigure ¶
type DDNSConfigure struct { Enable bool `json:"Enable"` HttpClientSecureVerify bool `json:"HttpClientSecureVerify"` FirstCheckDelay int `json:"FirstCheckDelay"` //首次检查延迟时间 Intervals int `json:"Intervals"` }
func GetDDNSConfigure ¶
func GetDDNSConfigure() DDNSConfigure
type DDNSTask ¶
type DDNSTask struct { TaskName string `json:"TaskName"` TaskKey string `json:"TaskKey"` //添加任务时随机生成,方便管理任务(修改删除) //规则类型 IPv4/IPv6 TaskType string `json:"TaskType"` Enable bool GetType string `json:"GetType"` URL []string `json:"URL"` NetInterface string `json:"NetInterface"` IPReg string `json:"IPReg"` Domains []string `json:"Domains"` DNS DNSConfig `json:"DNS"` Webhook TTL string `json:"TTL"` HttpClientTimeout int `json:"HttpClientTimeout"` }
func DeleteDDNSTaskListlice ¶
func GetDDNSTaskByKey ¶
func GetDDNSTaskConfigureList ¶ added in v1.2.1
func GetDDNSTaskConfigureList() []*DDNSTask
type DNSCallback ¶
type DNSCallback struct { URL string `json:"URL"` //请求地址 Method string `json:"Method"` //请求方法 Headers []string `json:"Headers"` RequestBody string `json:"RequestBody"` Server string `json:"Server"` //预设服务商 DisableCallbackSuccessContentCheck bool `json:"DisableCallbackSuccessContentCheck"` //禁用成功调用返回检测 CallbackSuccessContent []string `json:"CallbackSuccessContent"` //接口调用成功包含内容 }
type DNSConfig ¶
type DNSConfig struct { // 名称。如:alidns,webhook Name string `json:"Name"` ID string `json:"ID"` Secret string `json:"Secret"` ForceInterval int `json:"ForceInterval"` //(秒)即使IP没有变化,到一定时间后依然强制更新或先DNS解析比较IP再更新 ResolverDoaminCheck bool `json:"ResolverDoaminCheck"` //调用callback同步前先解析一次域名,如果IP相同就不同步 DNSServerList []string `json:"DNSServerList"` //DNS服务器列表 Callback DNSCallback `json:"Callback"` HttpClientProxyType string `json:"HttpClientProxyType"` //http client代理服务器设置 HttpClientProxyAddr string `json:"HttpClientProxyAddr"` //代理服务器IP HttpClientProxyUser string `json:"HttpClientProxyUser"` //代理用户 HttpClientProxyPassword string `json:"HttpClientProxyPassword"` //代理密码 }
DNSConfig DNS配置
type ProgramConfigure ¶
type ProgramConfigure struct { BaseConfigure BaseConfigure `json:"BaseConfigure"` RelayRuleList []ConfigureRelayRule `json:"RelayRuleList"` WhiteListConfigure WhiteListConfigure `json:"WhiteListConfigure"` BlackListConfigure BlackListConfigure `json:"BlackListConfigure"` DDNSConfigure DDNSConfigure `json:"DDNSConfigure"` //DDNS 参数设置 DDNSTaskList []DDNSTask `json:"DDNSTaskList"` //DDNS任务列表 ReverseProxyRuleList []ReverseProxyRule `json:"ReverseProxyRuleList"` //反向代理规则列表 }
func GetConfig ¶
func GetConfig() *ProgramConfigure
type ReverseProxy ¶ added in v1.3.1
type ReverseProxy struct { SubReverProxyRule Enable bool `json:"Enable"` Remark string `json:"Remark"` Domains []string `json:"Domains"` //自定义域名 }
type ReverseProxyRule ¶ added in v1.3.1
type ReverseProxyRule struct { RuleName string `json:"RuleName"` RuleKey string `json:"RuleKey"` Enable bool `json:"Enable"` ListenIP string `json:"ListenIP"` ListenPort int `json:"ListenPort"` EnableTLS bool `json:"EnableTLS"` Network string `json:"Network"` DefaultProxy struct { SubReverProxyRule } `json:"DefaultProxy"` ProxyList []ReverseProxy `json:"ProxyList"` // contains filtered or unexported fields }
func DeleteReverseProxyRuleListlice ¶ added in v1.3.1
func DeleteReverseProxyRuleListlice(a []ReverseProxyRule, deleteIndex int) []ReverseProxyRule
func GetReverseProxyRuleByKey ¶ added in v1.3.1
func GetReverseProxyRuleByKey(ruleKey string) *ReverseProxyRule
func GetReverseProxyRuleList ¶ added in v1.3.1
func GetReverseProxyRuleList() []*ReverseProxyRule
func (*ReverseProxyRule) Addr ¶ added in v1.3.1
func (r *ReverseProxyRule) Addr() string
func (*ReverseProxyRule) GetLastLogs ¶ added in v1.3.1
func (r *ReverseProxyRule) GetLastLogs() map[string][]any
func (*ReverseProxyRule) GetServer ¶ added in v1.3.1
func (r *ReverseProxyRule) GetServer() *http.Server
func (*ReverseProxyRule) GetSubRuleByDomain ¶ added in v1.3.1
func (r *ReverseProxyRule) GetSubRuleByDomain(domain string) (*ReverseProxy, bool)
func (*ReverseProxyRule) Init ¶ added in v1.3.1
func (r *ReverseProxyRule) Init()
func (*ReverseProxyRule) ReverseProxyHandler ¶ added in v1.3.1
func (r *ReverseProxyRule) ReverseProxyHandler(c *gin.Context)
func (*ReverseProxyRule) ServerStart ¶ added in v1.3.1
func (r *ReverseProxyRule) ServerStart() error
func (*ReverseProxyRule) ServerStop ¶ added in v1.3.1
func (r *ReverseProxyRule) ServerStop()
func (*ReverseProxyRule) SetServer ¶ added in v1.3.1
func (r *ReverseProxyRule) SetServer(s *http.Server)
type SubReverProxyRule ¶ added in v1.3.1
type SubReverProxyRule struct { Key string `json:"Key"` Locations []string `json:"Locations"` //长度大于1时均衡负载 EnableAccessLog bool `json:"EnableAccessLog"` //开启日志 LogLevel int `json:"LogLevel"` //日志输出级别 LogOutputToConsole bool `json:"LogOutputToConsole"` //日志输出到终端 AccessLogMaxNum int `json:"AccessLogMaxNum"` //最大条数 WebListShowLastLogMaxCount int `json:"WebListShowLastLogMaxCount"` //前端列表显示最新日志最大条数 RequestInfoLogFormat string `json:"RequestInfoLogFormat"` //请求信息在日志中的格式 ForwardedByClientIP bool `json:"ForwardedByClientIP"` TrustedCIDRsStrList []string `json:"TrustedCIDRsStrList"` RemoteIPHeaders []string `json:"RemoteIPHeaders"` //识别客户端原始IP的Http请求头 TrustedProxyCIDRs []*net.IPNet `json:"-"` AddRemoteIPToHeader bool `json:"AddRemoteIPToHeader"` //追加客户端连接IP到指定Header AddRemoteIPHeaderKey string `json:"AddRemoteIPHeaderKey"` EnableBasicAuth bool `json:"EnableBasicAuth"` //启用BasicAuth认证 BasicAuthUser string `json:"BasicAuthUser"` //如果配置此参数,暴露出去的 HTTP 服务需要采用 Basic Auth 的鉴权才能访问 BasicAuthPasswd string `json:"BasicAuthPasswd"` //结合 BasicAuthUser 使用 SafeIPMode string `json:"SafeIPMode"` //IP过滤模式 黑白名单 SafeUserAgentMode string `json:"SafeUserAgentMode"` //UserAgent 过滤模式 黑白名单 UserAgentfilter []string `json:"UserAgentfilter"` //UserAgent 过滤内容 CustomRobotTxt bool `json:"CustomRobotTxt"` RobotTxt string `json:"RobotTxt"` // contains filtered or unexported fields }
func GetSubRuleByKey ¶ added in v1.3.1
func GetSubRuleByKey(ruleKey, proxyKey string) *SubReverProxyRule
func (*SubReverProxyRule) BasicAuthHandler ¶ added in v1.3.1
func (r *SubReverProxyRule) BasicAuthHandler(c *gin.Context) bool
func (*SubReverProxyRule) ClientIP ¶ added in v1.3.1
func (r *SubReverProxyRule) ClientIP(c *gin.Context) string
func (*SubReverProxyRule) GetLocation ¶ added in v1.3.1
func (r *SubReverProxyRule) GetLocation() string
func (*SubReverProxyRule) GetLogger ¶ added in v1.3.1
func (r *SubReverProxyRule) GetLogger() *log.Logger
func (*SubReverProxyRule) GetLogrus ¶ added in v1.3.1
func (r *SubReverProxyRule) GetLogrus() *logrus.Logger
func (*SubReverProxyRule) GetLogsBuffer ¶ added in v1.3.1
func (r *SubReverProxyRule) GetLogsBuffer() *logsbuffer.LogsBuffer
func (*SubReverProxyRule) HandlerReverseProxy ¶ added in v1.3.1
func (*SubReverProxyRule) InitTrustedProxyCIDRs ¶ added in v1.3.1
func (r *SubReverProxyRule) InitTrustedProxyCIDRs() error
func (*SubReverProxyRule) PrintfToConsole ¶ added in v1.3.1
func (r *SubReverProxyRule) PrintfToConsole(entry *logrus.Entry) error
type Webhook ¶
type Webhook struct { WebhookEnable bool `json:"WebhookEnable"` //Webhook开关 WebhookCallOnGetIPfail bool `json:"WebhookCallOnGetIPfail"` //获取IP失败时触发Webhook 开关 WebhookURL string `json:"WebhookURL"` WebhookMethod string `json:"WebhookMethod"` WebhookHeaders []string `json:"WebhookHeaders"` WebhookRequestBody string `json:"WebhookRequestBody"` WebhookDisableCallbackSuccessContentCheck bool `json:"WebhookDisableCallbackSuccessContentCheck"` //禁用成功调用返回检测 WebhookSuccessContent []string `json:"WebhookSuccessContent"` //接口调用成功包含的内容 WebhookProxy string `json:"WebhookProxy"` //使用DNS代理设置 ""表示禁用,"dns"表示使用dns的代理设置 WebhookProxyAddr string `json:"WebhookProxyAddr"` //代理服务器IP WebhookProxyUser string `json:"WebhookProxyUser"` //代理用户 WebhookProxyPassword string `json:"WebhookProxyPassword"` //代理密码 }
type WhiteListBaseConfigure ¶
type WhiteListBaseConfigure struct { URL string `json:"URL"` ActivelifeDuration int32 `json:"ActivelifeDuration"` //有效期限,小时 BasicAccount string `json:"BasicAccount"` BasicPassword string `json:"BasicPassword"` }
func GetWhiteListBaseConfigure ¶
func GetWhiteListBaseConfigure() WhiteListBaseConfigure
type WhiteListConfigure ¶
type WhiteListConfigure struct { BaseConfigure WhiteListBaseConfigure `json:"BaseConfigure"` WhiteList []WhiteListItem `json:"WhiteList"` //白名单列表 }
type WhiteListItem ¶
type WhiteListItem struct { IP string `json:"IP"` EffectiveTime string `json:"Effectivetime"` //有效时间 NetIP net.IP `json:"-"` Cidr *net.IPNet `json:"-"` }
func DeleteWhiteListlice ¶
func DeleteWhiteListlice(a []WhiteListItem, deleteIndex int) []WhiteListItem
func GetWhiteList ¶
func GetWhiteList() []WhiteListItem
func (*WhiteListItem) Contains ¶ added in v1.3.1
func (w *WhiteListItem) Contains(ip string) bool
Click to show internal directories.
Click to hide internal directories.