diff options
author | kali kaneko (leap communications) <kali@leap.se> | 2020-01-25 22:06:41 -0600 |
---|---|---|
committer | kali kaneko (leap communications) <kali@leap.se> | 2020-01-25 22:06:41 -0600 |
commit | d35f3e153496f21ff89bc0f08e0dc436766c48f0 (patch) | |
tree | 79b1c9ebe058662f0fd1adb1139397a51c230d1b /pkg/auth/sip2/telnet.go | |
parent | 5bb198c1a5da3132945915947b88ad4a59dc7fcb (diff) |
get sip2 telnet terminator from env var
Diffstat (limited to 'pkg/auth/sip2/telnet.go')
-rw-r--r-- | pkg/auth/sip2/telnet.go | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/pkg/auth/sip2/telnet.go b/pkg/auth/sip2/telnet.go index b5abd5f..faa72ff 100644 --- a/pkg/auth/sip2/telnet.go +++ b/pkg/auth/sip2/telnet.go @@ -4,9 +4,10 @@ import ( "github.com/reiver/go-telnet" ) -// TODO depends on how terminator is configured -- take it from config file -// const terminator string = "\r\n" -const terminator string = "\r" +// The terminator can be configured differently for different SIP endpoints. +// This gets set in sip2.auth according to an environment variable + +var TelnetTerminator string func telnetRead(conn *telnet.Conn) (out string) { var buffer [1]byte @@ -21,7 +22,7 @@ func telnetRead(conn *telnet.Conn) (out string) { } else { out += string(recvData) } - if len(out) > 1 && out[len(out)-len(terminator):] == terminator { + if len(out) > 1 && out[len(out)-len(TelnetTerminator):] == TelnetTerminator { break } } @@ -35,7 +36,6 @@ func telnetSend(conn *telnet.Conn, command string) { } var crlfBuffer [2]byte = [2]byte{'\r', '\n'} - crlf := crlfBuffer[:] conn.Write(commandBuffer) |