add --allow-private-dst support for docker, bot and creator app
This commit is contained in:
1 parent
ca0966bc33
commit
d171a757aa
16 files changed
+129
-32
No files matched your search
@@ -42,5 +42,6 @@ set -- \
|
||||
[ -n "${UPSTREAM_SOCKS:-}" ] && set -- "$@" --upstream-socks "$UPSTREAM_SOCKS"
|
||||
[ -n "${UPSTREAM_USER:-}" ] && set -- "$@" --upstream-user "$UPSTREAM_USER"
|
||||
[ -n "${UPSTREAM_PASS:-}" ] && set -- "$@" --upstream-pass "$UPSTREAM_PASS"
|
||||
[ "${ALLOW_PRIVATE_DST:-0}" = "1" ] && set -- "$@" --allow-private-dst
|
||||
|
||||
exec /usr/local/bin/headless-vk-bot "$@"
|
||||
+23
-16
@@ -75,6 +75,8 @@ type bot struct {
|
||||
upstreamUser string
|
||||
upstreamPass string
|
||||
|
||||
allowPrivateDst bool
|
||||
|
||||
server, key, ts string
|
||||
|
||||
mu sync.Mutex
|
||||
@@ -379,6 +381,9 @@ func (b *bot) spawn(platform, joinTarget string) (*session, error) {
|
||||
args = append(args, "--upstream-pass", b.upstreamPass)
|
||||
}
|
||||
}
|
||||
if b.allowPrivateDst {
|
||||
args = append(args, "--allow-private-dst")
|
||||
}
|
||||
cmd := exec.Command(bin, args...)
|
||||
if logF != nil {
|
||||
cmd.Stdout = logF
|
||||
@@ -505,6 +510,7 @@ func main() {
|
||||
upstreamSocks := flag.String("upstream-socks", "", "forward to spawned creators: route tunneled egress through this SOCKS5 proxy (host:port), e.g. a local VPN client")
|
||||
upstreamUser := flag.String("upstream-user", "", "upstream SOCKS5 username forwarded to spawned creators")
|
||||
upstreamPass := flag.String("upstream-pass", "", "upstream SOCKS5 password forwarded to spawned creators")
|
||||
allowPrivateDst := flag.Bool("allow-private-dst", false, "forward to spawned creators: let the joiner reach private/internal addresses through them")
|
||||
flag.Parse()
|
||||
|
||||
if *token == "" {
|
||||
@@ -533,22 +539,23 @@ func main() {
|
||||
}
|
||||
|
||||
b := &bot{
|
||||
token: *token,
|
||||
groupID: *groupID,
|
||||
userIDs: allowedUsers,
|
||||
binsDir: *binsDir,
|
||||
vkCookies: *vkCookies,
|
||||
tmCookies: *tmCookies,
|
||||
wbCookies: *wbCookies,
|
||||
dionCookies: *dionCookies,
|
||||
bitrixCookies: *bitrixCookies,
|
||||
sessionsDir: *sessionsDir,
|
||||
resources: *resources,
|
||||
upstreamSocks: *upstreamSocks,
|
||||
upstreamUser: *upstreamUser,
|
||||
upstreamPass: *upstreamPass,
|
||||
sessions: map[string]*session{},
|
||||
awaitingJoin: map[int64]bool{},
|
||||
token: *token,
|
||||
groupID: *groupID,
|
||||
userIDs: allowedUsers,
|
||||
binsDir: *binsDir,
|
||||
vkCookies: *vkCookies,
|
||||
tmCookies: *tmCookies,
|
||||
wbCookies: *wbCookies,
|
||||
dionCookies: *dionCookies,
|
||||
bitrixCookies: *bitrixCookies,
|
||||
sessionsDir: *sessionsDir,
|
||||
resources: *resources,
|
||||
upstreamSocks: *upstreamSocks,
|
||||
upstreamUser: *upstreamUser,
|
||||
upstreamPass: *upstreamPass,
|
||||
allowPrivateDst: *allowPrivateDst,
|
||||
sessions: map[string]*session{},
|
||||
awaitingJoin: map[int64]bool{},
|
||||
}
|
||||
|
||||
sig := make(chan os.Signal, 1)
|
||||
|
||||
@@ -333,7 +333,7 @@ func (u *TunnelRelay) sendDCFrame(connID uint32, mt byte, payload []byte) {
|
||||
func (u *TunnelRelay) connectTCP(connID uint32, addr string) {
|
||||
log.Printf("[dc] CONNECT %d -> %s", connID, common.MaskAddr(addr))
|
||||
if common.DstBlocked(addr) {
|
||||
log.Printf("[dc] CONNECT %d blocked %s", connID, common.MaskAddr(addr))
|
||||
log.Printf("[dc] CONNECT %d blocked %s, private destinations need --allow-private-dst", connID, common.MaskAddr(addr))
|
||||
u.sendDCFrame(connID, tunnel.MsgConnectErr, []byte(common.ErrPrivateDst.Error()))
|
||||
return
|
||||
}
|
||||
@@ -408,8 +408,8 @@ func (u *TunnelRelay) handleUDP(connID uint32, payload []byte) {
|
||||
resp := make([]byte, common.UDPBufSize)
|
||||
|
||||
if common.DstBlocked(addr) {
|
||||
if common.Debug {
|
||||
log.Printf("[dc] UDP %d blocked %s", connID, common.MaskAddr(addr))
|
||||
if suppressed, ok := common.ClaimBlockedDstLog(); ok {
|
||||
log.Printf("[dc] UDP %d blocked %s, private destinations need --allow-private-dst, suppressed=%d", connID, common.MaskAddr(addr), suppressed)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user