Skip to content

Commit 14f6be6

Browse files
committed
Clean up scripts-proxy code
1 parent fc2fa3c commit 14f6be6

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

server/common/oursrc/scripts-proxy/ldap/conn.go

+6-7
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,12 @@ func (c *conn) resolvePool(hostname string) (string, error) {
4343
defer c.mu.Unlock()
4444

4545
escapedHostname := ldap.EscapeFilter(hostname)
46-
req := ldap.NewSearchRequest(
47-
c.baseDn,
48-
ldap.ScopeWholeSubtree, ldap.NeverDerefAliases, 0, 0, false,
49-
fmt.Sprintf("(|(scriptsVhostName=%s)(scriptsVhostAlias=%s))", escapedHostname, escapedHostname),
50-
[]string{"scriptsVhostPoolIPv4"},
51-
nil,
52-
)
46+
req := &ldap.SearchRequest{
47+
BaseDN: c.baseDn,
48+
Scope: ldap.ScopeWholeSubtree,
49+
Filter: fmt.Sprintf("(|(scriptsVhostName=%s)(scriptsVhostAlias=%s))", escapedHostname, escapedHostname),
50+
Attributes: []string{"scriptsVhostPoolIPv4"},
51+
}
5352
sr, err := c.conn.Search(req)
5453
if err != nil {
5554
return "", err

server/common/oursrc/scripts-proxy/main.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ func (l *ldapTarget) HandleConn(netConn net.Conn) {
6060
log.Printf("resolving default pool: %v", err)
6161
}
6262
}
63+
// TODO: Serve an error page? Forward to scripts-director?
6364
if pool == "" {
6465
netConn.Close()
6566
return
@@ -75,8 +76,8 @@ func (l *ldapTarget) HandleConn(netConn net.Conn) {
7576
dp := &tcpproxy.DialProxy{
7677
Addr: destAddrStr,
7778
}
78-
raddr := netConn.RemoteAddr().(*net.TCPAddr)
7979
if l.localPoolRange.Contains(destAddr.IP) {
80+
raddr := netConn.RemoteAddr().(*net.TCPAddr)
8081
td := &TransparentDialer{
8182
SourceAddr: &net.TCPAddr{
8283
IP: raddr.IP,

0 commit comments

Comments
 (0)