forked from vacuityv/vacproxy
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
241 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
name: test | ||
|
||
# 代理鉴权配置,enabled为true且user和password均不为空代表鉴权 | ||
auth: | ||
enabled: true | ||
user: test | ||
password: 1234 | ||
|
||
# 请求ip白名单,放空代表不限制 | ||
inAllowList: | ||
- 127.0.0.1 | ||
- 192.168.100.* | ||
|
||
# 目标域名/ip白名单,放空代表不限制 | ||
outAllowList: | ||
# - weixin.qq.com | ||
# - alipay.com | ||
# - baidu.com |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package service | ||
|
||
import ( | ||
"strings" | ||
) | ||
|
||
type Node struct { | ||
children map[string]*Node | ||
value bool | ||
} | ||
|
||
func NewNode() *Node { | ||
return &Node{ | ||
children: make(map[string]*Node), | ||
value: false, | ||
} | ||
} | ||
|
||
func (n *Node) Insert(domain string) { | ||
parts := strings.Split(domain, ".") | ||
node := n | ||
for _, part := range parts { | ||
if _, ok := node.children[part]; !ok { | ||
node.children[part] = NewNode() | ||
} | ||
node = node.children[part] | ||
} | ||
node.value = true | ||
} | ||
|
||
func (n *Node) Match(domain string) bool { | ||
parts := strings.Split(domain, ".") | ||
node := n | ||
for i, part := range parts { | ||
if child, ok := node.children[part]; ok { | ||
node = child | ||
} else if child, ok := node.children["*"]; ok && i == len(parts)-1 { | ||
node = child | ||
} else { | ||
return false | ||
} | ||
if node.value { | ||
return true | ||
} | ||
} | ||
return false | ||
} |
Oops, something went wrong.