Skip to content

Commit 2190f7d

Browse files
committed
Clean up scripts-proxy code
1 parent 7e4e4d4 commit 2190f7d

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

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

Lines changed: 6 additions & 7 deletions
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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ func (l *ldapTarget) HandleConn(netConn net.Conn) {
6363
log.Printf("resolving default pool: %v", err)
6464
}
6565
}
66+
// TODO: Serve an error page? Forward to scripts-director?
6667
if pool == "" {
6768
netConn.Close()
6869
return
@@ -78,8 +79,8 @@ func (l *ldapTarget) HandleConn(netConn net.Conn) {
7879
dp := &tcpproxy.DialProxy{
7980
Addr: destAddrStr,
8081
}
81-
raddr := netConn.RemoteAddr().(*net.TCPAddr)
8282
if l.localPoolRange.Contains(destAddr.IP) {
83+
raddr := netConn.RemoteAddr().(*net.TCPAddr)
8384
td := &TransparentDialer{
8485
SourceAddr: &net.TCPAddr{
8586
IP: raddr.IP,

0 commit comments

Comments
 (0)