equal
deleted
inserted
replaced
95 |
95 |
96 struct session_tree sessions; |
96 struct session_tree sessions; |
97 static int _pop3_debug = 0; |
97 static int _pop3_debug = 0; |
98 |
98 |
99 void |
99 void |
100 session_init(struct listener *l, int fd) |
100 session_init(struct listener *l, int fd, const struct sockaddr_storage *ss) |
101 { |
101 { |
102 struct session *s; |
102 struct session *s; |
103 void *ssl; |
103 void *ssl; |
104 extern void *ssl_ctx; |
104 extern void *ssl_ctx; |
105 |
105 |
106 s = xcalloc(1, sizeof(*s), "session_init"); |
106 s = xcalloc(1, sizeof(*s), "session_init"); |
107 s->l = l; |
107 s->l = l; |
|
108 memmove(&s->ss, ss, sizeof(*ss)); |
108 if (iobuf_init(&s->iobuf, 0, 0) == -1) |
109 if (iobuf_init(&s->iobuf, 0, 0) == -1) |
109 fatal("iobuf_init"); |
110 fatal("iobuf_init"); |
110 |
111 |
111 io_init(&s->io, fd, s, session_io, &s->iobuf); |
112 io_init(&s->io, fd, s, session_io, &s->iobuf); |
112 io_set_timeout(&s->io, TIMEOUT); |
113 io_set_timeout(&s->io, TIMEOUT); |
118 io_set_read(&s->io); |
119 io_set_read(&s->io); |
119 io_start_tls(&s->io, ssl); |
120 io_start_tls(&s->io, ssl); |
120 return; |
121 return; |
121 } |
122 } |
122 |
123 |
123 log_connect(s->id, &l->ss, l->ss.ss_len); |
124 log_connect(s->id, &s->ss, s->ss.ss_len); |
124 SPLAY_INSERT(session_tree, &sessions, s); |
125 SPLAY_INSERT(session_tree, &sessions, s); |
125 session_reply(s, "%s", "+OK pop3d ready"); |
126 session_reply(s, "%s", "+OK pop3d ready"); |
126 io_set_write(&s->io); |
127 io_set_write(&s->io); |
127 } |
128 } |
128 |
129 |
186 io_set_read(io); |
187 io_set_read(io); |
187 break; |
188 break; |
188 case IO_TLSREADY: |
189 case IO_TLSREADY: |
189 /* greet only for pop3s, STLS already greeted */ |
190 /* greet only for pop3s, STLS already greeted */ |
190 if (s->flags & POP3S) { |
191 if (s->flags & POP3S) { |
191 log_connect(s->id, &s->l->ss, s->l->ss.ss_len); |
192 log_connect(s->id, &s->ss, s->ss.ss_len); |
192 session_reply(s, "%s", "+OK pop3 ready"); |
193 session_reply(s, "%s", "+OK pop3 ready"); |
193 io_set_write(&s->io); |
194 io_set_write(&s->io); |
194 } |
195 } |
195 SPLAY_INSERT(session_tree, &sessions, s); |
196 SPLAY_INSERT(session_tree, &sessions, s); |
196 /* mark STLS session as secure */ |
197 /* mark STLS session as secure */ |