12.06.2015 Views

The Annoyance Filter.pdf - Fourmilab

The Annoyance Filter.pdf - Fourmilab

The Annoyance Filter.pdf - Fourmilab

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

§205 ANNOYANCE-FILTER POP3 PROXY SERVER CLASS DEFINITION 171<br />

205. Read the next request from the client. Requests are always a single line consisting of POP_MAX_MESSAGE<br />

characters or fewer.<br />

〈 Read request from client 205 〉 ≡<br />

if (popProxyTrace ) {<br />

cerr ≪ "POP3:␣Reading␣request␣from␣client." ≪ endl ;<br />

}<br />

clientLength = recv (clientSocket , clientBuffer , POP_MAX_MESSAGE, 0);<br />

if (popProxyTrace ) {<br />

cerr ≪ "POP3:␣Read␣" ≪ clientLength ≪ "␣request␣bytes␣from␣client." ≪ endl ;<br />

}<br />

if (clientLength ≤ 0) {<br />

break;<br />

}<br />

This code is used in section 204.<br />

206. RFC 1939 is silent on the issue, but the POP3 server I tested with seems to silently discard<br />

blank lines without issuing an “−ERR” response. Since this can hang up our proxy cycle, eat blank lines<br />

without passing them on to the server. This shouldn’t happen with a properly operating client, but it’s<br />

all too easy to do when testing with Telnet, and besides, we have to cope with screwball clients which<br />

may do anything.<br />

〈 Check for blank request and discard 206 〉 ≡<br />

if (isspace (clientBuffer [0])) {<br />

continue;<br />

}<br />

This code is used in section 204.<br />

207. Pass on the client request to the server.<br />

〈 Forward request to server 207 〉 ≡<br />

serverLength = send (serverSocket , clientBuffer , clientLength , 0);<br />

if (serverLength ≠ clientLength ) {<br />

perror ("POP3Proxy␣forwarding␣request␣to␣server");<br />

break;<br />

}<br />

This code is used in section 204.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!