|
@@ -33,7 +33,7 @@ type Server struct {
|
33
|
33
|
motdLines []string
|
34
|
34
|
name Name
|
35
|
35
|
nameString string // cache for server name string since it's used with almost every reply
|
36
|
|
- newConns chan net.Conn
|
|
36
|
+ newConns chan clientConn
|
37
|
37
|
operators map[Name][]byte
|
38
|
38
|
password []byte
|
39
|
39
|
signals chan os.Signal
|
|
@@ -48,6 +48,11 @@ var (
|
48
|
48
|
syscall.SIGTERM, syscall.SIGQUIT}
|
49
|
49
|
)
|
50
|
50
|
|
|
51
|
+type clientConn struct {
|
|
52
|
+ Conn net.Conn
|
|
53
|
+ IsTLS bool
|
|
54
|
+}
|
|
55
|
+
|
51
|
56
|
func NewServer(config *Config) *Server {
|
52
|
57
|
server := &Server{
|
53
|
58
|
channels: make(ChannelNameMap),
|
|
@@ -58,7 +63,7 @@ func NewServer(config *Config) *Server {
|
58
|
63
|
idle: make(chan *Client),
|
59
|
64
|
name: NewName(config.Server.Name),
|
60
|
65
|
nameString: NewName(config.Server.Name).String(),
|
61
|
|
- newConns: make(chan net.Conn),
|
|
66
|
+ newConns: make(chan clientConn),
|
62
|
67
|
operators: config.Operators(),
|
63
|
68
|
signals: make(chan os.Signal, len(SERVER_SIGNALS)),
|
64
|
69
|
proxyAllowedFrom: config.Server.ProxyAllowedFrom,
|
|
@@ -180,7 +185,7 @@ func (server *Server) Run() {
|
180
|
185
|
done = true
|
181
|
186
|
|
182
|
187
|
case conn := <-server.newConns:
|
183
|
|
- NewClient(server, conn)
|
|
188
|
+ NewClient(server, conn.Conn, conn.IsTLS)
|
184
|
189
|
|
185
|
190
|
/*TODO(dan): LOOK AT THIS MORE CLOSELY
|
186
|
191
|
case cmd := <-server.commands:
|
|
@@ -221,7 +226,12 @@ func (s *Server) listen(addr string, tlsMap map[Name]*tls.Config) {
|
221
|
226
|
}
|
222
|
227
|
Log.debug.Printf("%s accept: %s", s, conn.RemoteAddr())
|
223
|
228
|
|
224
|
|
- s.newConns <- conn
|
|
229
|
+ newConn := clientConn{
|
|
230
|
+ Conn: conn,
|
|
231
|
+ IsTLS: listenTLS,
|
|
232
|
+ }
|
|
233
|
+
|
|
234
|
+ s.newConns <- newConn
|
225
|
235
|
}
|
226
|
236
|
}()
|
227
|
237
|
}
|
|
@@ -250,7 +260,11 @@ func (s *Server) wslisten(addr string, tlsMap map[string]*TLSListenConfig) {
|
250
|
260
|
return
|
251
|
261
|
}
|
252
|
262
|
|
253
|
|
- s.newConns <- WSContainer{ws}
|
|
263
|
+ newConn := clientConn{
|
|
264
|
+ Conn: WSContainer{ws},
|
|
265
|
+ IsTLS: false, //TODO(dan): track TLS or not here properly
|
|
266
|
+ }
|
|
267
|
+ s.newConns <- newConn
|
254
|
268
|
})
|
255
|
269
|
go func() {
|
256
|
270
|
config, listenTLS := tlsMap[addr]
|
|
@@ -294,6 +308,7 @@ func (s *Server) tryRegister(c *Client) {
|
294
|
308
|
c.Send(nil, s.nameString, RPL_MYINFO, c.nickString, s.nameString, SEM_VER, supportedUserModesString, supportedChannelModesString)
|
295
|
309
|
c.RplISupport()
|
296
|
310
|
s.MOTD(c)
|
|
311
|
+ c.Send(nil, c.nickMaskString, RPL_UMODEIS, c.nickString, c.ModeString())
|
297
|
312
|
}
|
298
|
313
|
|
299
|
314
|
func (server *Server) MOTD(client *Client) {
|