3 | #else
4 | #include "fts_compat.h"
5 | #endif
6 |
7 |
--------------------------------------------------------------------------------
/Frameworks/polipo-20091115/http.h:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (c) 2003-2006 by Juliusz Chroboczek
3 |
4 | Permission is hereby granted, free of charge, to any person obtaining a copy
5 | of this software and associated documentation files (the "Software"), to deal
6 | in the Software without restriction, including without limitation the rights
7 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | copies of the Software, and to permit persons to whom the Software is
9 | furnished to do so, subject to the following conditions:
10 |
11 | The above copyright notice and this permission notice shall be included in
12 | all copies or substantial portions of the Software.
13 |
14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 | THE SOFTWARE.
21 | */
22 |
23 | typedef struct _HTTPCondition {
24 | time_t ims;
25 | time_t inms;
26 | char *im;
27 | char *inm;
28 | char *ifrange;
29 | } HTTPConditionRec, *HTTPConditionPtr;
30 |
31 | typedef struct _HTTPRequest {
32 | int flags;
33 | struct _HTTPConnection *connection;
34 | ObjectPtr object;
35 | int method;
36 | int from;
37 | int to;
38 | CacheControlRec cache_control;
39 | HTTPConditionPtr condition;
40 | AtomPtr via;
41 | struct _ConditionHandler *chandler;
42 | ObjectPtr can_mutate;
43 | int error_code;
44 | struct _Atom *error_message;
45 | struct _Atom *error_headers;
46 | AtomPtr headers;
47 | struct timeval time0, time1;
48 | struct _HTTPRequest *request;
49 | struct _HTTPRequest *next;
50 | } HTTPRequestRec, *HTTPRequestPtr;
51 |
52 | /* request->flags */
53 | #define REQUEST_PERSISTENT 1
54 | #define REQUEST_REQUESTED 2
55 | #define REQUEST_WAIT_CONTINUE 4
56 | #define REQUEST_FORCE_ERROR 8
57 | #define REQUEST_PIPELINED 16
58 |
59 | typedef struct _HTTPConnection {
60 | int flags;
61 | int fd;
62 | char *buf;
63 | int len;
64 | int offset;
65 | HTTPRequestPtr request;
66 | HTTPRequestPtr request_last;
67 | int serviced;
68 | int version;
69 | int time;
70 | TimeEventHandlerPtr timeout;
71 | int te;
72 | char *reqbuf;
73 | int reqlen;
74 | int reqbegin;
75 | int reqoffset;
76 | int bodylen;
77 | int reqte;
78 | /* For server connections */
79 | int chunk_remaining;
80 | struct _HTTPServer *server;
81 | int pipelined;
82 | int connecting;
83 | } HTTPConnectionRec, *HTTPConnectionPtr;
84 |
85 | /* connection->flags */
86 | #define CONN_READER 1
87 | #define CONN_WRITER 2
88 | #define CONN_SIDE_READER 4
89 | #define CONN_BIGBUF 8
90 | #define CONN_BIGREQBUF 16
91 |
92 | /* request->method */
93 | #define METHOD_UNKNOWN -1
94 | #define METHOD_NONE -1
95 | #define METHOD_GET 0
96 | #define METHOD_HEAD 1
97 | #define METHOD_CONDITIONAL_GET 2
98 | #define METHOD_CONNECT 3
99 | #define METHOD_POST 4
100 | #define METHOD_PUT 5
101 |
102 | #define REQUEST_SIDE(request) ((request)->method >= METHOD_POST)
103 |
104 | /* server->version */
105 | #define HTTP_10 0
106 | #define HTTP_11 1
107 | #define HTTP_UNKNOWN -1
108 |
109 | /* connection->te */
110 | #define TE_IDENTITY 0
111 | #define TE_CHUNKED 1
112 | #define TE_UNKNOWN -1
113 |
114 | /* connection->connecting */
115 | #define CONNECTING_DNS 1
116 | #define CONNECTING_CONNECT 2
117 | #define CONNECTING_SOCKS 3
118 |
119 | /* the results of a conditional request. 200, 304 and 412. */
120 | #define CONDITION_MATCH 0
121 | #define CONDITION_NOT_MODIFIED 1
122 | #define CONDITION_FAILED 2
123 |
124 | extern int disableProxy;
125 | extern AtomPtr proxyName;
126 | extern int proxyPort;
127 | extern int clientTimeout, serverTimeout, serverIdleTimeout;
128 | extern int bigBufferSize;
129 | extern AtomPtr proxyAddress;
130 | extern int proxyOffline;
131 | extern int relaxTransparency;
132 | extern AtomPtr authRealm;
133 | extern AtomPtr authCredentials;
134 | extern AtomPtr parentAuthCredentials;
135 | extern AtomListPtr allowedClients;
136 | extern NetAddressPtr allowedNets;
137 | extern IntListPtr allowedPorts;
138 | extern IntListPtr tunnelAllowedPorts;
139 | extern int expectContinue;
140 | extern AtomPtr atom100Continue;
141 | extern int disableVia;
142 | extern int dontTrustVaryETag;
143 |
144 | void preinitHttp(void);
145 | void initHttp(void);
146 |
147 | int httpTimeoutHandler(TimeEventHandlerPtr);
148 | int httpSetTimeout(HTTPConnectionPtr connection, int secs);
149 | int httpWriteObjectHeaders(char *buf, int offset, int len,
150 | ObjectPtr object, int from, int to);
151 | int httpPrintCacheControl(char*, int, int, int, CacheControlPtr);
152 | char *httpMessage(int) ATTRIBUTE((pure));
153 | int htmlString(char *buf, int n, int len, char *s, int slen);
154 | void htmlPrint(FILE *out, char *s, int slen);
155 | HTTPConnectionPtr httpMakeConnection(void);
156 | void httpDestroyConnection(HTTPConnectionPtr connection);
157 | void httpConnectionDestroyBuf(HTTPConnectionPtr connection);
158 | void httpConnectionDestroyReqbuf(HTTPConnectionPtr connection);
159 | HTTPRequestPtr httpMakeRequest(void);
160 | void httpDestroyRequest(HTTPRequestPtr request);
161 | void httpQueueRequest(HTTPConnectionPtr, HTTPRequestPtr);
162 | HTTPRequestPtr httpDequeueRequest(HTTPConnectionPtr connection);
163 | int httpConnectionBigify(HTTPConnectionPtr);
164 | int httpConnectionBigifyReqbuf(HTTPConnectionPtr);
165 | int httpConnectionUnbigify(HTTPConnectionPtr);
166 | int httpConnectionUnbigifyReqbuf(HTTPConnectionPtr);
167 | HTTPConditionPtr httpMakeCondition(void);
168 | void httpDestroyCondition(HTTPConditionPtr condition);
169 | int httpCondition(ObjectPtr, HTTPConditionPtr);
170 | int httpWriteErrorHeaders(char *buf, int size, int offset, int do_body,
171 | int code, AtomPtr message, int close, AtomPtr,
172 | char *url, int url_len, char *etag);
173 | AtomListPtr urlDecode(char*, int);
174 | void httpTweakCachability(ObjectPtr);
175 | int httpHeaderMatch(AtomPtr header, AtomPtr headers1, AtomPtr headers2);
176 |
--------------------------------------------------------------------------------
/Frameworks/polipo-20091115/http_parse.h:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (c) 2003-2006 by Juliusz Chroboczek
3 |
4 | Permission is hereby granted, free of charge, to any person obtaining a copy
5 | of this software and associated documentation files (the "Software"), to deal
6 | in the Software without restriction, including without limitation the rights
7 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | copies of the Software, and to permit persons to whom the Software is
9 | furnished to do so, subject to the following conditions:
10 |
11 | The above copyright notice and this permission notice shall be included in
12 | all copies or substantial portions of the Software.
13 |
14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 | THE SOFTWARE.
21 | */
22 |
23 | typedef struct HTTPRange {
24 | int from;
25 | int to;
26 | int full_length;
27 | } HTTPRangeRec, *HTTPRangePtr;
28 |
29 | extern int censorReferer;
30 | extern AtomPtr atomContentType, atomContentEncoding;
31 |
32 | void preinitHttpParser(void);
33 | void initHttpParser(void);
34 | int httpParseClientFirstLine(const char *buf, int offset,
35 | int *method_return,
36 | AtomPtr *url_return,
37 | int *version_return);
38 | int httpParseServerFirstLine(const char *buf,
39 | int *status_return,
40 | int *version_return,
41 | AtomPtr *message_return);
42 |
43 | int findEndOfHeaders(const char *buf, int from, int to, int *body_return);
44 |
45 | int httpParseHeaders(int, AtomPtr, const char *, int, HTTPRequestPtr,
46 | AtomPtr*, int*, CacheControlPtr,
47 | HTTPConditionPtr *, int*,
48 | time_t*, time_t*, time_t*, time_t*, time_t*,
49 | int*, int*, char**, AtomPtr*,
50 | HTTPRangePtr, HTTPRangePtr, char**, AtomPtr*, AtomPtr*);
51 | int httpFindHeader(AtomPtr header, const char *headers, int hlen,
52 | int *value_begin_return, int *value_end_return);
53 | int parseUrl(const char *url, int len,
54 | int *x_return, int *y_return, int *port_return, int *z_return);
55 | int urlIsLocal(const char *url, int len);
56 | int urlIsSpecial(const char *url, int len);
57 | int parseChunkSize(const char *buf, int i, int end, int *chunk_size_return);
58 | int checkVia(AtomPtr, AtomPtr);
59 |
--------------------------------------------------------------------------------
/Frameworks/polipo-20091115/io.h:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (c) 2003-2006 by Juliusz Chroboczek
3 |
4 | Permission is hereby granted, free of charge, to any person obtaining a copy
5 | of this software and associated documentation files (the "Software"), to deal
6 | in the Software without restriction, including without limitation the rights
7 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | copies of the Software, and to permit persons to whom the Software is
9 | furnished to do so, subject to the following conditions:
10 |
11 | The above copyright notice and this permission notice shall be included in
12 | all copies or substantial portions of the Software.
13 |
14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 | THE SOFTWARE.
21 | */
22 |
23 | /* request->operation */
24 | #define IO_READ 0
25 | #define IO_WRITE 1
26 | #define IO_MASK 0xFF
27 | /* Do not initiate operation now -- wait for the poll loop. */
28 | #define IO_NOTNOW 0x100
29 | /* Call the progress handler once if no data arrives immediately. */
30 | #define IO_IMMEDIATE 0x200
31 | /* Emit a chunk length before every write operation */
32 | #define IO_CHUNKED 0x400
33 | /* Emit a zero-length chunk at the end if chunked */
34 | #define IO_END 0x800
35 |
36 | /* Internal -- header is really buf3 */
37 | #define IO_BUF3 0x1000
38 | /* Internal -- header is really buf_location */
39 | #define IO_BUF_LOCATION 0x2000
40 |
41 | typedef struct _StreamRequest {
42 | short operation;
43 | short fd;
44 | int offset;
45 | int len;
46 | int len2;
47 | union {
48 | struct {
49 | int hlen;
50 | char *header;
51 | } h;
52 | struct {
53 | int len3;
54 | char *buf3;
55 | } b;
56 | struct {
57 | char **buf_location;
58 | } l;
59 | } u;
60 | char *buf;
61 | char *buf2;
62 | int (*handler)(int, FdEventHandlerPtr, struct _StreamRequest*);
63 | void *data;
64 | } StreamRequestRec, *StreamRequestPtr;
65 |
66 | typedef struct _ConnectRequest {
67 | int fd;
68 | int af;
69 | struct _Atom *addr;
70 | int firstindex;
71 | int index;
72 | int port;
73 | int (*handler)(int, FdEventHandlerPtr, struct _ConnectRequest*);
74 | void *data;
75 | } ConnectRequestRec, *ConnectRequestPtr;
76 |
77 | typedef struct _AcceptRequest {
78 | int fd;
79 | int (*handler)(int, FdEventHandlerPtr, struct _AcceptRequest*);
80 | void *data;
81 | } AcceptRequestRec, *AcceptRequestPtr;
82 |
83 | void preinitIo();
84 | void initIo();
85 |
86 | FdEventHandlerPtr
87 | do_stream(int operation, int fd, int offset, char *buf, int len,
88 | int (*handler)(int, FdEventHandlerPtr, StreamRequestPtr),
89 | void *data);
90 |
91 | FdEventHandlerPtr
92 | do_stream_h(int operation, int fd, int offset,
93 | char *header, int hlen, char *buf, int len,
94 | int (*handler)(int, FdEventHandlerPtr, StreamRequestPtr),
95 | void *data);
96 |
97 | FdEventHandlerPtr
98 | do_stream_2(int operation, int fd, int offset,
99 | char *buf, int len, char *buf2, int len2,
100 | int (*handler)(int, FdEventHandlerPtr, StreamRequestPtr),
101 | void *data);
102 |
103 | FdEventHandlerPtr
104 | do_stream_3(int operation, int fd, int offset,
105 | char *buf, int len, char *buf2, int len2, char *buf3, int len3,
106 | int (*handler)(int, FdEventHandlerPtr, StreamRequestPtr),
107 | void *data);
108 |
109 | FdEventHandlerPtr
110 | do_stream_buf(int operation, int fd, int offset, char **buf_location, int len,
111 | int (*handler)(int, FdEventHandlerPtr, StreamRequestPtr),
112 | void *data);
113 |
114 | FdEventHandlerPtr
115 | schedule_stream(int operation, int fd, int offset,
116 | char *header, int hlen,
117 | char *buf, int len, char *buf2, int len2, char *buf3, int len3,
118 | char **buf_location,
119 | int (*handler)(int, FdEventHandlerPtr, StreamRequestPtr),
120 | void *data);
121 |
122 | int do_scheduled_stream(int, FdEventHandlerPtr);
123 | int streamRequestDone(StreamRequestPtr);
124 |
125 | FdEventHandlerPtr
126 | do_connect(struct _Atom *addr, int index, int port,
127 | int (*handler)(int, FdEventHandlerPtr, ConnectRequestPtr),
128 | void *data);
129 |
130 | int do_scheduled_connect(int, FdEventHandlerPtr event);
131 |
132 | FdEventHandlerPtr
133 | do_accept(int fd,
134 | int (*handler)(int, FdEventHandlerPtr, AcceptRequestPtr),
135 | void* data);
136 |
137 | FdEventHandlerPtr
138 | schedule_accept(int fd,
139 | int (*handler)(int, FdEventHandlerPtr, AcceptRequestPtr),
140 | void* data);
141 |
142 | int do_scheduled_accept(int, FdEventHandlerPtr event);
143 |
144 | FdEventHandlerPtr
145 | create_listener(char *address, int port,
146 | int (*handler)(int, FdEventHandlerPtr, AcceptRequestPtr),
147 | void *data);
148 | int setNonblocking(int fd, int nonblocking);
149 | int setNodelay(int fd, int nodelay);
150 | int setV6only(int fd, int v6only);
151 | int lingeringClose(int fd);
152 |
153 | typedef struct _NetAddress {
154 | int prefix;
155 | int af;
156 | unsigned char data[16];
157 | } NetAddressRec, *NetAddressPtr;
158 |
159 | NetAddressPtr parseNetAddress(AtomListPtr list);
160 | int netAddressMatch(int fd, NetAddressPtr list) ATTRIBUTE ((pure));
161 |
162 |
--------------------------------------------------------------------------------
/Frameworks/polipo-20091115/local.h:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (c) 2003, 2004 by Juliusz Chroboczek
3 |
4 | Permission is hereby granted, free of charge, to any person obtaining a copy
5 | of this software and associated documentation files (the "Software"), to deal
6 | in the Software without restriction, including without limitation the rights
7 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | copies of the Software, and to permit persons to whom the Software is
9 | furnished to do so, subject to the following conditions:
10 |
11 | The above copyright notice and this permission notice shall be included in
12 | all copies or substantial portions of the Software.
13 |
14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 | THE SOFTWARE.
21 | */
22 |
23 | typedef struct _SpecialRequest {
24 | ObjectPtr object;
25 | int fd;
26 | void *buf;
27 | int offset;
28 | pid_t pid;
29 | } SpecialRequestRec, *SpecialRequestPtr;
30 |
31 | extern int disableConfiguration;
32 | extern int disableIndexing;
33 |
34 | void preinitLocal(void);
35 | void alternatingHttpStyle(FILE *out, char *id);
36 | int httpLocalRequest(ObjectPtr object, int method, int from, int to,
37 | HTTPRequestPtr, void *);
38 | int httpSpecialRequest(ObjectPtr object, int method, int from, int to,
39 | HTTPRequestPtr, void*);
40 | int httpSpecialSideRequest(ObjectPtr object, int method, int from, int to,
41 | HTTPRequestPtr requestor, void *closure);
42 | int specialRequestHandler(int status,
43 | FdEventHandlerPtr event, StreamRequestPtr request);
44 | int httpSpecialDoSide(HTTPRequestPtr requestor);
45 | int httpSpecialClientSideHandler(int status,
46 | FdEventHandlerPtr event,
47 | StreamRequestPtr srequest);
48 | int httpSpecialDoSideFinish(AtomPtr data, HTTPRequestPtr requestor);
49 |
--------------------------------------------------------------------------------
/Frameworks/polipo-20091115/localindex.html:
--------------------------------------------------------------------------------
1 |
3 |
4 | Welcome to Polipo
5 |
6 | Welcome to Polipo
7 |
8 | The Polipo manual.
9 |
10 |
The configuration interface.
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/Frameworks/polipo-20091115/log.h:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (c) 2003-2006 by Juliusz Chroboczek
3 |
4 | Permission is hereby granted, free of charge, to any person obtaining a copy
5 | of this software and associated documentation files (the "Software"), to deal
6 | in the Software without restriction, including without limitation the rights
7 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | copies of the Software, and to permit persons to whom the Software is
9 | furnished to do so, subject to the following conditions:
10 |
11 | The above copyright notice and this permission notice shall be included in
12 | all copies or substantial portions of the Software.
13 |
14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 | THE SOFTWARE.
21 | */
22 |
23 | #define L_ERROR 0x1
24 | #define L_WARN 0x2
25 | #define L_INFO 0x4
26 | #define L_FORBIDDEN 0x8
27 | #define L_UNCACHEABLE 0x10
28 | #define L_SUPERSEDED 0x20
29 | #define L_VARY 0x40
30 |
31 | #define D_SERVER_CONN 0x100
32 | #define D_SERVER_REQ 0x200
33 | #define D_CLIENT_CONN 0x400
34 | #define D_CLIENT_REQ 0x800
35 | #define D_ATOM_REFCOUNT 0x1000
36 | #define D_REFCOUNT 0x2000
37 | #define D_LOCK 0x4000
38 | #define D_OBJECT 0x8000
39 | #define D_OBJECT_DATA 0x10000
40 | #define D_SERVER_OFFSET 0x20000
41 | #define D_CLIENT_DATA 0x40000
42 | #define D_DNS 0x80000
43 | #define D_CHILD 0x100000
44 | #define D_IO 0x200000
45 |
46 | #define LOGGING_DEFAULT (L_ERROR | L_WARN | L_INFO)
47 | #define LOGGING_MAX 0xFF
48 |
49 | extern int scrubLogs;
50 |
51 | void preinitLog(void);
52 | void initLog(void);
53 | void reopenLog(void);
54 | void flushLog(void);
55 | int loggingToStderr(void);
56 |
57 | void really_do_log(int type, const char *f, ...)
58 | ATTRIBUTE ((format (printf, 2, 3)));
59 | void really_do_log_v(int type, const char *f, va_list args)
60 | ATTRIBUTE ((format (printf, 2, 0)));
61 | void really_do_log_n(int type, const char *s, int n);
62 | void really_do_log_error(int type, int e, const char *f, ...)
63 | ATTRIBUTE ((format (printf, 3, 4)));
64 | void really_do_log_error_v(int type, int e, const char *f, va_list args)
65 | ATTRIBUTE ((format (printf, 3, 0)));
66 | const char *scrub(const char *message);
67 |
68 |
69 | #ifdef __GNUC__
70 | #define DO_BACKTRACE() \
71 | do { \
72 | int n; \
73 | void *buffer[10]; \
74 | n = backtrace(buffer, 5); \
75 | fflush(stderr); \
76 | backtrace_symbols_fd(buffer, n, 2); \
77 | } while(0)
78 | #else
79 | #define DO_BACKTRACE() /* */
80 | #endif
81 |
82 | /* These are macros because it's important that they should be
83 | optimised away. */
84 |
85 | #if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L
86 |
87 | #define do_log(_type, ...) \
88 | do { \
89 | if((_type) & (LOGGING_MAX)) really_do_log((_type), __VA_ARGS__); \
90 | } while(0)
91 | #define do_log_error(_type, _e, ...) \
92 | do { \
93 | if((_type) & (LOGGING_MAX)) \
94 | really_do_log_error((_type), (_e), __VA_ARGS__); \
95 | } while(0)
96 |
97 | #elif defined(__GNUC__)
98 |
99 | #define do_log(_type, _args...) \
100 | do { \
101 | if((_type) & (LOGGING_MAX)) really_do_log((_type), _args); \
102 | } while(0)
103 | #define do_log_error(_type, _e, _args...) \
104 | do { \
105 | if((_type) & (LOGGING_MAX)) \
106 | really_do_log_error((_type), (_e), _args); \
107 | } while(0)
108 |
109 | #else
110 |
111 | /* No variadic macros -- let's hope inline works. */
112 |
113 | static inline void
114 | do_log(int type, const char *f, ...)
115 | {
116 | va_list args;
117 |
118 | va_start(args, f);
119 | if((type & (LOGGING_MAX)) != 0)
120 | really_do_log_v(type, f, args);
121 | va_end(args);
122 | }
123 |
124 | static inline void
125 | do_log_error(int type, int e, const char *f, ...)
126 | {
127 | va_list args;
128 |
129 | va_start(args, f);
130 | if((type & (LOGGING_MAX)) != 0)
131 | really_do_log_error_v(type, e, f, args);
132 | va_end(args);
133 | }
134 |
135 | #endif
136 |
137 | #define do_log_n(_type, _s, _n) \
138 | do { \
139 | if((_type) & (LOGGING_MAX)) really_do_log_n((_type), (_s), (_n)); \
140 | } while(0)
141 |
--------------------------------------------------------------------------------
/Frameworks/polipo-20091115/main.c:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (c) 2003-2006 by Juliusz Chroboczek
3 |
4 | Permission is hereby granted, free of charge, to any person obtaining a copy
5 | of this software and associated documentation files (the "Software"), to deal
6 | in the Software without restriction, including without limitation the rights
7 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | copies of the Software, and to permit persons to whom the Software is
9 | furnished to do so, subject to the following conditions:
10 |
11 | The above copyright notice and this permission notice shall be included in
12 | all copies or substantial portions of the Software.
13 |
14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 | THE SOFTWARE.
21 | */
22 |
23 | #include "polipo.h"
24 |
25 | AtomPtr configFile = NULL;
26 | AtomPtr pidFile = NULL;
27 | int daemonise = 0;
28 |
29 | static void
30 | usage(char *argv0)
31 | {
32 | fprintf(stderr,
33 | "%s [ -h ] [ -v ] [ -x ] [ -c filename ] [ -- ] [ var=val... ]\n",
34 | argv0);
35 | fprintf(stderr, " -h: display this message.\n");
36 | fprintf(stderr, " -v: display the list of configuration variables.\n");
37 | fprintf(stderr, " -x: perform expiry on the disk cache.\n");
38 | fprintf(stderr, " -c: specify the configuration file to use.\n");
39 | }
40 |
41 | extern ConfigVariablePtr configVariables;
42 |
43 | int
44 | polipo_main(int argc, char **argv)
45 | {
46 | FdEventHandlerPtr listener;
47 | int i;
48 | int rc;
49 | int expire = 0, printConfig = 0;
50 |
51 | configFile = NULL;
52 | pidFile = NULL;
53 | configVariables = NULL;
54 |
55 | initAtoms();
56 | CONFIG_VARIABLE(daemonise, CONFIG_BOOLEAN, "Run as a daemon");
57 | CONFIG_VARIABLE(pidFile, CONFIG_ATOM, "File with pid of running daemon.");
58 |
59 | preinitChunks();
60 | preinitLog();
61 | preinitObject();
62 | preinitIo();
63 | preinitDns();
64 | preinitServer();
65 | preinitHttp();
66 | preinitDiskcache();
67 | preinitLocal();
68 | preinitForbidden();
69 | preinitSocks();
70 |
71 | i = 1;
72 | while(i < argc) {
73 | if(argv[i][0] != '-')
74 | break;
75 | if(strcmp(argv[i], "--") == 0) {
76 | i++;
77 | break;
78 | } else if(strcmp(argv[i], "-h") == 0) {
79 | usage(argv[0]);
80 | exit(0);
81 | } else if(strcmp(argv[i], "-v") == 0) {
82 | printConfig = 1;
83 | i++;
84 | } else if(strcmp(argv[i], "-x") == 0) {
85 | expire = 1;
86 | i++;
87 | } else if(strcmp(argv[i], "-c") == 0) {
88 | i++;
89 | if(i >= argc) {
90 | usage(argv[0]);
91 | exit(1);
92 | }
93 | if(configFile)
94 | releaseAtom(configFile);
95 | configFile = internAtom(argv[i]);
96 | i++;
97 | } else {
98 | usage(argv[0]);
99 | exit(1);
100 | }
101 | }
102 |
103 | if(configFile)
104 | configFile = expandTilde(configFile);
105 |
106 | if(configFile == NULL) {
107 | configFile = expandTilde(internAtom("~/.polipo"));
108 | if(configFile)
109 | if(access(configFile->string, F_OK) < 0) {
110 | releaseAtom(configFile);
111 | configFile = NULL;
112 | }
113 | }
114 |
115 | if(configFile == NULL) {
116 | if(access("/etc/polipo/config", F_OK) >= 0)
117 | configFile = internAtom("/etc/polipo/config");
118 | if(configFile && access(configFile->string, F_OK) < 0) {
119 | releaseAtom(configFile);
120 | configFile = NULL;
121 | }
122 | }
123 |
124 | rc = parseConfigFile(configFile);
125 | if(rc < 0)
126 | exit(1);
127 |
128 | while(i < argc) {
129 | rc = parseConfigLine(argv[i], "command line", 0, 0);
130 | if(rc < 0)
131 | exit(1);
132 | i++;
133 | }
134 |
135 | initChunks();
136 | initLog();
137 | initObject();
138 | if(!expire && !printConfig)
139 | initEvents();
140 | initIo();
141 | initDns();
142 | initHttp();
143 | initServer();
144 | initDiskcache();
145 | initForbidden();
146 | initSocks();
147 |
148 | if(printConfig) {
149 | printConfigVariables(stdout, 0);
150 | exit(0);
151 | }
152 |
153 | if(expire) {
154 | expireDiskObjects();
155 | exit(0);
156 | }
157 |
158 | if(daemonise)
159 | do_daemonise(loggingToStderr());
160 |
161 | if(pidFile)
162 | writePid(pidFile->string);
163 |
164 | listener = create_listener(proxyAddress->string,
165 | proxyPort, httpAccept, NULL);
166 | if(!listener) {
167 | if(pidFile) unlink(pidFile->string);
168 | exit(1);
169 | }
170 |
171 | eventLoop();
172 |
173 | close(listener->fd);
174 |
175 | if(pidFile) unlink(pidFile->string);
176 | return 0;
177 | }
--------------------------------------------------------------------------------
/Frameworks/polipo-20091115/md5.h:
--------------------------------------------------------------------------------
1 | /*
2 | ***********************************************************************
3 | ** md5.h -- header file for implementation of MD5 **
4 | ** RSA Data Security, Inc. MD5 Message-Digest Algorithm **
5 | ** Created: 2/17/90 RLR **
6 | ** Revised: 12/27/90 SRD,AJ,BSK,JT Reference C version **
7 | ** Revised (for MD5): RLR 4/27/91 **
8 | ***********************************************************************
9 | */
10 |
11 | /*
12 | ***********************************************************************
13 | ** Copyright (C) 1990, RSA Data Security, Inc. All rights reserved. **
14 | ** **
15 | ** License to copy and use this software is granted provided that **
16 | ** it is identified as the "RSA Data Security, Inc. MD5 Message- **
17 | ** Digest Algorithm" in all material mentioning or referencing this **
18 | ** software or this function. **
19 | ** **
20 | ** License is also granted to make and use derivative works **
21 | ** provided that such works are identified as "derived from the RSA **
22 | ** Data Security, Inc. MD5 Message-Digest Algorithm" in all **
23 | ** material mentioning or referencing the derived work. **
24 | ** **
25 | ** RSA Data Security, Inc. makes no representations concerning **
26 | ** either the merchantability of this software or the suitability **
27 | ** of this software for any particular purpose. It is provided "as **
28 | ** is" without express or implied warranty of any kind. **
29 | ** **
30 | ** These notices must be retained in any copies of any part of this **
31 | ** documentation and/or software. **
32 | ***********************************************************************
33 | */
34 |
35 | #ifdef HAS_STDINT_H
36 | #include
37 | #elif defined(HAS_INTTYPES_H)
38 | #include
39 | #endif
40 |
41 | /* typedef a 32-bit type */
42 | typedef uint32_t UINT4;
43 | //typedef unsigned int UINT4;
44 |
45 | /* Data structure for MD5 (Message-Digest) computation */
46 | typedef struct {
47 | UINT4 i[2]; /* number of _bits_ handled mod 2^64 */
48 | UINT4 buf[4]; /* scratch buffer */
49 | unsigned char in[64]; /* input buffer */
50 | unsigned char digest[16]; /* actual digest after MD5Final call */
51 | } MD5_CTX;
52 |
53 | void MD5Init (MD5_CTX *mdContext);
54 | void MD5Update (MD5_CTX *, unsigned const char *, unsigned int);
55 | void MD5Final (MD5_CTX *);
56 |
57 | /*
58 | ***********************************************************************
59 | ** End of md5.h **
60 | ******************************** (cut) ********************************
61 | */
62 |
--------------------------------------------------------------------------------
/Frameworks/polipo-20091115/md5import.c:
--------------------------------------------------------------------------------
1 | #ifndef _GNU_SOURCE
2 | #define _GNU_SOURCE
3 | #endif
4 |
5 | #include
6 |
7 | #if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L
8 | #define HAS_STDINT_H
9 | #else
10 | typedef unsigned int my_uint32_t;
11 | #undef uint32_t
12 | #define uint32_t my_uint32_t
13 | #endif
14 | #include "md5.c"
15 | #undef uint32_t
16 |
--------------------------------------------------------------------------------
/Frameworks/polipo-20091115/md5import.h:
--------------------------------------------------------------------------------
1 | #if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L
2 | #define HAS_STDINT_H
3 | #else
4 | typedef unsigned int my_uint32_t;
5 | #undef uint32_t
6 | #define uint32_t my_uint32_t
7 | #endif
8 | #include "md5.h"
9 | #undef uint32_t
10 |
--------------------------------------------------------------------------------
/Frameworks/polipo-20091115/mingw.h:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (c) 2006 by Dan Kennedy.
3 | Copyright (c) 2006 by Juliusz Chroboczek.
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in
13 | all copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | THE SOFTWARE.
22 | */
23 |
24 | /*
25 | * Polipo was originally designed to run on Unix-like systems. This
26 | * header file (and it's accompanying implementation file mingw.c) contain
27 | * code that allows polipo to run on Microsoft Windows too.
28 | *
29 | * The target MS windows compiler is Mingw (MINimal Gnu for Windows). The
30 | * code in this file probably get's us pretty close to MSVC also, but
31 | * this has not been tested. To build polipo for Mingw, define the MINGW
32 | * symbol. For Unix or Unix-like systems, leave it undefined.
33 | */
34 |
35 | #ifdef MINGW
36 |
37 | /* Unfortunately, there's no hiding it. */
38 | #define HAVE_WINSOCK 1
39 |
40 | /* At time of writing, a fair bit of stuff doesn't work under Mingw.
41 | * Hopefully they will be fixed later (especially the disk-cache).
42 | */
43 | #define NO_IPv6 1
44 |
45 | #include
46 |
47 | #define S_IROTH S_IREAD
48 |
49 | /* Pull in winsock.h for (almost) berkeley sockets. */
50 | #include
51 | #define ENOTCONN WSAENOTCONN
52 | #define EWOULDBLOCK WSAEWOULDBLOCK
53 | #define ENOBUFS WSAENOBUFS
54 | #define ECONNRESET WSAECONNRESET
55 | #define ESHUTDOWN WSAESHUTDOWN
56 | #define EAFNOSUPPORT WSAEAFNOSUPPORT
57 | #define EPROTONOSUPPORT WSAEPROTONOSUPPORT
58 | #define EINPROGRESS WSAEINPROGRESS
59 | #define EISCONN WSAEISCONN
60 |
61 | /* winsock doesn't feature poll(), so there is a version implemented
62 | * in terms of select() in mingw.c. The following definitions
63 | * are copied from linux man pages. A poll() macro is defined to
64 | * call the version in mingw.c.
65 | */
66 | #define POLLIN 0x0001 /* There is data to read */
67 | #define POLLPRI 0x0002 /* There is urgent data to read */
68 | #define POLLOUT 0x0004 /* Writing now will not block */
69 | #define POLLERR 0x0008 /* Error condition */
70 | #define POLLHUP 0x0010 /* Hung up */
71 | #define POLLNVAL 0x0020 /* Invalid request: fd not open */
72 | struct pollfd {
73 | SOCKET fd; /* file descriptor */
74 | short events; /* requested events */
75 | short revents; /* returned events */
76 | };
77 | #define poll(x, y, z) mingw_poll(x, y, z)
78 |
79 | /* These wrappers do nothing special except set the global errno variable if
80 | * an error occurs (winsock doesn't do this by default). They set errno
81 | * to unix-like values (i.e. WSAEWOULDBLOCK is mapped to EAGAIN), so code
82 | * outside of this file "shouldn't" have to worry about winsock specific error
83 | * handling.
84 | */
85 | #define socket(x, y, z) mingw_socket(x, y, z)
86 | #define connect(x, y, z) mingw_connect(x, y, z)
87 | #define accept(x, y, z) mingw_accept(x, y, z)
88 | #define shutdown(x, y) mingw_shutdown(x, y)
89 | #define getpeername(x, y, z) mingw_getpeername(x, y, z)
90 |
91 | /* Wrapper macros to call misc. functions mingw is missing */
92 | #define sleep(x) mingw_sleep(x)
93 | #define inet_aton(x, y) mingw_inet_aton(x, y)
94 | #define gettimeofday(x, y) mingw_gettimeofday(x, y)
95 | #define stat(x, y) mingw_stat(x, y)
96 |
97 | #define mkdir(x, y) mkdir(x)
98 |
99 | /* Winsock uses int instead of the usual socklen_t */
100 | typedef int socklen_t;
101 |
102 | /* Function prototypes for functions in mingw.c */
103 | unsigned int mingw_sleep(unsigned int);
104 | int mingw_inet_aton(const char *, struct in_addr *);
105 | int mingw_gettimeofday(struct timeval *, char *);
106 | int mingw_poll(struct pollfd *, unsigned int, int);
107 | SOCKET mingw_socket(int, int, int);
108 | int mingw_connect(SOCKET, struct sockaddr*, socklen_t);
109 | SOCKET mingw_accept(SOCKET, struct sockaddr*, socklen_t *);
110 | int mingw_shutdown(SOCKET, int);
111 | int mingw_getpeername(SOCKET, struct sockaddr*, socklen_t *);
112 |
113 | /* Three socket specific macros */
114 | #define READ(x, y, z) mingw_read_socket(x, y, z)
115 | #define WRITE(x, y, z) mingw_write_socket(x, y, z)
116 | #define CLOSE(x) mingw_close_socket(x)
117 |
118 | int mingw_read_socket(SOCKET, void *, int);
119 | int mingw_write_socket(SOCKET, void *, int);
120 | int mingw_close_socket(SOCKET);
121 |
122 | int mingw_setnonblocking(SOCKET, int);
123 | int mingw_stat(const char*, struct stat*);
124 | #endif
125 |
126 | #ifndef HAVE_READV_WRITEV
127 | /*
128 | * The HAVE_READV_WRITEV symbol should be defined if the system features
129 | * the vector IO functions readv() and writev() and those functions may
130 | * be legally used with sockets.
131 | */
132 | struct iovec {
133 | void *iov_base; /* Starting address */
134 | size_t iov_len; /* Number of bytes */
135 | };
136 | #define WRITEV(x, y, z) polipo_writev(x, y, z)
137 | #define READV(x, y, z) polipo_readv(x, y, z)
138 | int polipo_readv(int fd, const struct iovec *vector, int count);
139 | int polipo_writev(int fd, const struct iovec *vector, int count);
140 | #endif
141 |
--------------------------------------------------------------------------------
/Frameworks/polipo-20091115/object.h:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (c) 2003-2006 by Juliusz Chroboczek
3 |
4 | Permission is hereby granted, free of charge, to any person obtaining a copy
5 | of this software and associated documentation files (the "Software"), to deal
6 | in the Software without restriction, including without limitation the rights
7 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | copies of the Software, and to permit persons to whom the Software is
9 | furnished to do so, subject to the following conditions:
10 |
11 | The above copyright notice and this permission notice shall be included in
12 | all copies or substantial portions of the Software.
13 |
14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 | THE SOFTWARE.
21 | */
22 |
23 | #undef MAX
24 | #undef MIN
25 |
26 | #define MAX(x,y) ((x)<=(y)?(y):(x))
27 | #define MIN(x,y) ((x)<=(y)?(x):(y))
28 |
29 | struct _HTTPRequest;
30 |
31 | #if defined(USHRT_MAX) && CHUNK_SIZE <= USHRT_MAX
32 | typedef unsigned short chunk_size_t;
33 | #else
34 | typedef unsigned int chunk_size_t;
35 | #endif
36 |
37 | typedef struct _Chunk {
38 | short int locked;
39 | chunk_size_t size;
40 | char *data;
41 | } ChunkRec, *ChunkPtr;
42 |
43 | struct _Object;
44 |
45 | typedef int (*RequestFunction)(struct _Object *, int, int, int,
46 | struct _HTTPRequest*, void*);
47 |
48 | typedef struct _Object {
49 | short refcount;
50 | unsigned char type;
51 | RequestFunction request;
52 | void *request_closure;
53 | char *key;
54 | unsigned short key_size;
55 | unsigned short flags;
56 | unsigned short code;
57 | void *abort_data;
58 | struct _Atom *message;
59 | int length;
60 | time_t date;
61 | time_t age;
62 | time_t expires;
63 | time_t last_modified;
64 | time_t atime;
65 | char *etag;
66 | unsigned short cache_control;
67 | int max_age;
68 | int s_maxage;
69 | struct _Atom *headers;
70 | struct _Atom *via;
71 | int size;
72 | int numchunks;
73 | ChunkPtr chunks;
74 | void *requestor;
75 | struct _Condition condition;
76 | struct _DiskCacheEntry *disk_entry;
77 | struct _Object *next, *previous;
78 | } ObjectRec, *ObjectPtr;
79 |
80 | typedef struct _CacheControl {
81 | int flags;
82 | int max_age;
83 | int s_maxage;
84 | int min_fresh;
85 | int max_stale;
86 | } CacheControlRec, *CacheControlPtr;
87 |
88 | extern int cacheIsShared;
89 | extern int mindlesslyCacheVary;
90 |
91 | extern CacheControlRec no_cache_control;
92 | extern int objectExpiryScheduled;
93 | extern int publicObjectCount;
94 | extern int privateObjectCount;
95 | extern int idleTime;
96 |
97 | extern const time_t time_t_max;
98 |
99 | extern int publicObjectLowMark, objectHighMark;
100 |
101 | extern int log2ObjectHashTableSize;
102 |
103 | /* object->type */
104 | #define OBJECT_HTTP 1
105 | #define OBJECT_DNS 2
106 |
107 | /* object->flags */
108 | /* object is public */
109 | #define OBJECT_PUBLIC 1
110 | /* object hasn't got any headers yet */
111 | #define OBJECT_INITIAL 2
112 | /* a server connection is already taking care of the object */
113 | #define OBJECT_INPROGRESS 4
114 | /* the object has been superseded -- don't try to fetch it */
115 | #define OBJECT_SUPERSEDED 8
116 | /* the object is private and aditionally can only be used by its requestor */
117 | #define OBJECT_LINEAR 16
118 | /* the object is currently being validated */
119 | #define OBJECT_VALIDATING 32
120 | /* object has been aborted */
121 | #define OBJECT_ABORTED 64
122 | /* last object request was a failure */
123 | #define OBJECT_FAILED 128
124 | /* Object is a local file */
125 | #define OBJECT_LOCAL 256
126 | /* The object's data has been entirely written out to disk */
127 | #define OBJECT_DISK_ENTRY_COMPLETE 512
128 | /* The object is suspected to be dynamic -- don't PMM */
129 | #define OBJECT_DYNAMIC 1024
130 | /* Used for synchronisation between client and server. */
131 | #define OBJECT_MUTATING 2048
132 |
133 | /* object->cache_control and connection->cache_control */
134 | /* RFC 2616 14.9 */
135 | /* Non-standard: like no-cache, but kept internally */
136 | #define CACHE_NO_HIDDEN 1
137 | /* no-cache */
138 | #define CACHE_NO 2
139 | /* public */
140 | #define CACHE_PUBLIC 4
141 | /* private */
142 | #define CACHE_PRIVATE 8
143 | /* no-store */
144 | #define CACHE_NO_STORE 16
145 | /* no-transform */
146 | #define CACHE_NO_TRANSFORM 32
147 | /* must-revalidate */
148 | #define CACHE_MUST_REVALIDATE 64
149 | /* proxy-revalidate */
150 | #define CACHE_PROXY_REVALIDATE 128
151 | /* only-if-cached */
152 | #define CACHE_ONLY_IF_CACHED 256
153 | /* set if Vary header; treated as no-cache */
154 | #define CACHE_VARY 512
155 | /* set if Authorization header; treated specially */
156 | #define CACHE_AUTHORIZATION 1024
157 | /* set if cookie */
158 | #define CACHE_COOKIE 2048
159 | /* set if this object should never be combined with another resource */
160 | #define CACHE_MISMATCH 4096
161 |
162 | struct _HTTPRequest;
163 |
164 | void preinitObject(void);
165 | void initObject(void);
166 | ObjectPtr findObject(int type, const void *key, int key_size);
167 | ObjectPtr makeObject(int type, const void *key, int key_size,
168 | int public, int fromdisk,
169 | int (*request)(ObjectPtr, int, int, int,
170 | struct _HTTPRequest*, void*), void*);
171 | void objectMetadataChanged(ObjectPtr object, int dirty);
172 | ObjectPtr retainObject(ObjectPtr);
173 | void releaseObject(ObjectPtr);
174 | int objectSetChunks(ObjectPtr object, int numchunks);
175 | void lockChunk(ObjectPtr, int);
176 | void unlockChunk(ObjectPtr, int);
177 | void destroyObject(ObjectPtr object);
178 | void privatiseObject(ObjectPtr object, int linear);
179 | void abortObject(ObjectPtr object, int code, struct _Atom *message);
180 | void supersedeObject(ObjectPtr);
181 | void notifyObject(ObjectPtr);
182 | void releaseNotifyObject(ObjectPtr);
183 | ObjectPtr objectPartial(ObjectPtr object, int length, struct _Atom *headers);
184 | int objectHoleSize(ObjectPtr object, int offset)
185 | ATTRIBUTE ((pure));
186 | int objectHasData(ObjectPtr object, int from, int to)
187 | ATTRIBUTE ((pure));
188 | int objectAddData(ObjectPtr object, const char *data, int offset, int len);
189 | void objectPrintf(ObjectPtr object, int offset, const char *format, ...)
190 | ATTRIBUTE ((format (printf, 3, 4)));
191 | int discardObjectsHandler(TimeEventHandlerPtr);
192 | void writeoutObjects(int);
193 | int discardObjects(int all, int force);
194 | int objectIsStale(ObjectPtr object, CacheControlPtr cache_control)
195 | ATTRIBUTE ((pure));
196 | int objectMustRevalidate(ObjectPtr object, CacheControlPtr cache_control)
197 | ATTRIBUTE ((pure));
198 |
--------------------------------------------------------------------------------
/Frameworks/polipo-20091115/parse_time.c:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (c) 2003-2006 by Juliusz Chroboczek
3 |
4 | Permission is hereby granted, free of charge, to any person obtaining a copy
5 | of this software and associated documentation files (the "Software"), to deal
6 | in the Software without restriction, including without limitation the rights
7 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | copies of the Software, and to permit persons to whom the Software is
9 | furnished to do so, subject to the following conditions:
10 |
11 | The above copyright notice and this permission notice shall be included in
12 | all copies or substantial portions of the Software.
13 |
14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 | THE SOFTWARE.
21 | */
22 |
23 | #include "polipo.h"
24 |
25 | const time_t time_t_max = ((time_t)~(1U << 31));
26 |
27 | static inline int
28 | d2i(char c)
29 | {
30 | if(c >= '0' && c <= '9')
31 | return c - '0';
32 | else
33 | return -1;
34 | }
35 |
36 | static int
37 | parse_int(const char *buf, int i, int len, int *val_return)
38 | {
39 | int val, d;
40 |
41 | if(i >= len)
42 | return -1;
43 |
44 | val = d2i(buf[i]);
45 | if(val < 0)
46 | return -1;
47 | else
48 | i++;
49 |
50 | while(i < len) {
51 | d = d2i(buf[i]);
52 | if(d < 0)
53 | break;
54 | val = val * 10 + d;
55 | i++;
56 | }
57 | *val_return = val;
58 | return i;
59 | }
60 |
61 | static const char month_names[12][3] = {
62 | "jan", "feb", "mar", "apr", "may", "jun",
63 | "jul", "aug", "sep", "oct", "nov", "dec",
64 | };
65 |
66 | static int
67 | skip_word(const char *buf, int i, int len)
68 | {
69 | if(i >= len)
70 | return -1;
71 |
72 | if(!letter(buf[i]))
73 | return -1;
74 |
75 | while(i < len) {
76 | if(!letter(buf[i]))
77 | break;
78 | i++;
79 | }
80 |
81 | return i;
82 | }
83 |
84 | static int
85 | parse_month(const char *buf, int i, int len, int *val_return)
86 | {
87 | int j, k, l;
88 | j = skip_word(buf, i, len);
89 | if(j != i + 3)
90 | return -1;
91 | for(k = 0; k < 12; k++) {
92 | for(l = 0; l < 3; l++) {
93 | if(lwr(buf[i + l]) != month_names[k][l])
94 | break;
95 | }
96 | if(l == 3)
97 | break;
98 | }
99 | if(k >= 12)
100 | return -1;
101 | *val_return = k;
102 | return j;
103 | }
104 |
105 | static int
106 | issep(char c)
107 | {
108 | return c == ' ' || c == '\t' || c == ',' || c == ':' || c == '-';
109 | }
110 |
111 | int
112 | skip_separator(const char *buf, int i, int len)
113 | {
114 | if(i >= len)
115 | return -1;
116 |
117 | if(issep(buf[i]))
118 | i++;
119 | else
120 | return -1;
121 |
122 | while(i < len) {
123 | if(issep(buf[i]))
124 | i++;
125 | else
126 | break;
127 | }
128 | return i;
129 | }
130 |
131 | int
132 | parse_time(const char *buf, int offset, int len, time_t *time_return)
133 | {
134 | struct tm tm;
135 | time_t t;
136 | int i = offset;
137 |
138 | i = skip_word(buf, i, len); if(i < 0) return -1;
139 | i = skip_separator(buf, i, len); if(i < 0) return -1;
140 |
141 | if(i >= len)
142 | return -1;
143 |
144 | if(d2i(buf[i]) >= 0) {
145 | i = parse_int(buf, i, len, &tm.tm_mday); if(i < 0) return -1;
146 | i = skip_separator(buf, i, len); if(i < 0) return -1;
147 | i = parse_month(buf, i, len, &tm.tm_mon); if(i < 0) return -1;
148 | i = skip_separator(buf, i, len); if(i < 0) return -1;
149 | i = parse_int(buf, i, len, &tm.tm_year); if(i < 0) return -1;
150 | if(tm.tm_year < 100)
151 | tm.tm_year += 1900;
152 | if(tm.tm_year < 1937)
153 | tm.tm_year += 100;
154 | if(tm.tm_year < 1937)
155 | return -1;
156 |
157 | i = skip_separator(buf, i, len); if(i < 0) return -1;
158 | i = parse_int(buf, i, len, &tm.tm_hour); if(i < 0) return -1;
159 | i = skip_separator(buf, i, len); if(i < 0) return -1;
160 | i = parse_int(buf, i, len, &tm.tm_min); if(i < 0) return -1;
161 | i = skip_separator(buf, i, len); if(i < 0) return -1;
162 | i = parse_int(buf, i, len, &tm.tm_sec); if(i < 0) return -1;
163 | i = skip_separator(buf, i, len); if(i < 0) return -1;
164 | i = skip_word(buf, i, len); if(i < 0) return -1;
165 | } else { /* funny American format */
166 | i = parse_month(buf, i, len, &tm.tm_mon); if(i < 0) return -1;
167 | i = skip_separator(buf, i, len); if(i < 0) return -1;
168 | i = parse_int(buf, i, len, &tm.tm_mday); if(i < 0) return -1;
169 | i = skip_separator(buf, i, len); if(i < 0) return -1;
170 | i = parse_int(buf, i, len, &tm.tm_hour); if(i < 0) return -1;
171 | i = skip_separator(buf, i, len); if(i < 0) return -1;
172 | i = parse_int(buf, i, len, &tm.tm_min); if(i < 0) return -1;
173 | i = skip_separator(buf, i, len); if(i < 0) return -1;
174 | i = parse_int(buf, i, len, &tm.tm_sec); if(i < 0) return -1;
175 | i = skip_separator(buf, i, len); if(i < 0) return -1;
176 | i = parse_int(buf, i, len, &tm.tm_year); if(i < 0) return -1;
177 | if(tm.tm_year < 100)
178 | tm.tm_year += 1900;
179 | if(tm.tm_year < 1937)
180 | tm.tm_year += 100;
181 | if(tm.tm_year < 1937 || tm.tm_year > 2040)
182 | return -1;
183 | }
184 |
185 | if(tm.tm_year < 2038) {
186 | tm.tm_year -= 1900;
187 | tm.tm_isdst = -1;
188 | t = mktime_gmt(&tm);
189 | if(t == -1)
190 | return -1;
191 | } else {
192 | t = time_t_max;
193 | }
194 |
195 | *time_return = t;
196 | return i;
197 | }
198 |
199 | int
200 | format_time(char *buf, int i, int len, time_t t)
201 | {
202 | struct tm *tm;
203 | int rc;
204 |
205 | if(i < 0 || i > len)
206 | return -1;
207 |
208 | tm = gmtime(&t);
209 | if(tm == NULL)
210 | return -1;
211 | rc = strftime(buf + i, len - i, "%a, %d %b %Y %H:%M:%S GMT", tm);
212 | if(rc <= 0) /* yes, that's <= */
213 | return -1;
214 | return i + rc;
215 | }
216 |
--------------------------------------------------------------------------------
/Frameworks/polipo-20091115/parse_time.h:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (c) 2003-2006 by Juliusz Chroboczek
3 |
4 | Permission is hereby granted, free of charge, to any person obtaining a copy
5 | of this software and associated documentation files (the "Software"), to deal
6 | in the Software without restriction, including without limitation the rights
7 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | copies of the Software, and to permit persons to whom the Software is
9 | furnished to do so, subject to the following conditions:
10 |
11 | The above copyright notice and this permission notice shall be included in
12 | all copies or substantial portions of the Software.
13 |
14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 | THE SOFTWARE.
21 | */
22 |
23 | /* XXX */
24 | extern const time_t time_t_max;
25 |
26 | int parse_time(const char *buf, int i, int len, time_t *time_return);
27 | int format_time(char *buf, int i, int len, time_t t);
28 |
--------------------------------------------------------------------------------
/Frameworks/polipo-20091115/polipo.h:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (c) 2003-2006 by Juliusz Chroboczek
3 |
4 | Permission is hereby granted, free of charge, to any person obtaining a copy
5 | of this software and associated documentation files (the "Software"), to deal
6 | in the Software without restriction, including without limitation the rights
7 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | copies of the Software, and to permit persons to whom the Software is
9 | furnished to do so, subject to the following conditions:
10 |
11 | The above copyright notice and this permission notice shall be included in
12 | all copies or substantial portions of the Software.
13 |
14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 | THE SOFTWARE.
21 | */
22 |
23 | #ifndef _GNU_SOURCE
24 | #define _GNU_SOURCE
25 | #endif
26 |
27 | #include
28 |
29 | #ifdef __MINGW32_VERSION
30 | #define MINGW
31 | #endif
32 |
33 | #include
34 | #include
35 | #include
36 | #include
37 | #include
38 | #include
39 | #include
40 | #include
41 | #include
42 | #include
43 | #include
44 | #include
45 | #include
46 | #ifndef MINGW
47 | #include
48 | #include
49 | #include
50 | #include
51 | #include
52 | #include
53 | #include
54 | #include
55 | #include
56 | #include
57 | #include
58 | #include
59 | #endif
60 |
61 | #ifndef MAP_ANONYMOUS
62 | #define MAP_ANONYMOUS MAP_ANON
63 | #endif
64 |
65 | #if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
66 | /* nothing */
67 | #elif defined(__GNUC__)
68 | #define inline __inline
69 | #if (__GNUC__ >= 3)
70 | #define restrict __restrict
71 | #else
72 | #define restrict /**/
73 | #endif
74 | #else
75 | #define inline /**/
76 | #define restrict /**/
77 | #endif
78 |
79 | #if defined(__GNUC__) && (__GNUC__ >= 3)
80 | #define ATTRIBUTE(x) __attribute__(x)
81 | #else
82 | #define ATTRIBUTE(x) /**/
83 | #endif
84 |
85 | #if defined __GLIBC__
86 | #define HAVE_TM_GMTOFF
87 | #ifndef __UCLIBC__
88 | #define HAVE_TIMEGM
89 | #define HAVE_FTS
90 | #define HAVE_FFSL
91 | #define HAVE_FFSLL
92 | #endif
93 | #define HAVE_SETENV
94 | #define HAVE_ASPRINTF
95 | #if (__GLIBC__ > 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 2)
96 | #define HAVE_MEMRCHR
97 | #endif
98 | #endif
99 |
100 | #if defined(__linux__) && (__GNU_LIBRARY__ == 1)
101 | /* Linux libc 5 */
102 | #define HAVE_TIMEGM
103 | #define HAVE_SETENV
104 | #endif
105 |
106 | #ifdef BSD
107 | #define HAVE_TM_GMTOFF
108 | #define HAVE_FTS
109 | #define HAVE_SETENV
110 | #endif
111 |
112 | #ifdef __CYGWIN__
113 | #define HAVE_SETENV
114 | #define HAVE_ASPRINTF
115 | #endif
116 |
117 | #ifndef O_BINARY
118 | #define O_BINARY 0
119 | #endif
120 |
121 | #define HAVE_TZSET
122 |
123 | #if _POSIX_VERSION >= 200112L
124 | #define HAVE_SETENV
125 | #endif
126 |
127 | #ifndef NO_IPv6
128 |
129 | #ifdef __GLIBC__
130 | #if (__GLIBC__ > 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 2)
131 | #define HAVE_IPv6
132 | #endif
133 | #endif
134 |
135 | #ifdef __FreeBSD__
136 | #define HAVE_ASPRINTF
137 | #if __FreeBSD_version >= 400000
138 | #define HAVE_IPv6
139 | #define HAVE_TIMEGM
140 | #endif
141 | #if __FreeBSD_version >= 503001
142 | #define HAVE_FFSL
143 | #endif
144 | #endif
145 |
146 | #ifdef __NetBSD__
147 | #if __NetBSD_Version__ >= 105000000
148 | #define HAVE_IPv6
149 | #endif
150 | #if __NetBSD_Version__ >= 200000000
151 | #define HAVE_TIMEGM
152 | #define HAVE_ASPRINTF
153 | #endif
154 | #endif
155 |
156 | #ifdef __OpenBSD__
157 | #if OpenBSD >= 200311
158 | #define HAVE_IPv6
159 | #endif
160 | #endif
161 |
162 | #endif
163 |
164 | #if defined(i386) || defined(__mc68020__) || defined(__x86_64__)
165 | #define UNALIGNED_ACCESS
166 | #endif
167 |
168 | #ifndef MINGW
169 | #define HAVE_FORK
170 | #ifndef NO_SYSLOG
171 | #define HAVE_SYSLOG
172 | #endif
173 | #define HAVE_READV_WRITEV
174 | #define HAVE_FFS
175 | #define READ(x, y, z) read(x, y, z)
176 | #define WRITE(x, y, z) write(x, y, z)
177 | #define CLOSE(x) close(x)
178 | #else
179 | #ifndef HAVE_REGEX
180 | #define NO_FORBIDDEN
181 | #endif
182 | #endif
183 |
184 | #ifdef HAVE_READV_WRITEV
185 | #define WRITEV(x, y, z) writev(x, y, z)
186 | #define READV(x, y, z) readv(x, y, z)
187 | #endif
188 |
189 | #ifndef HAVE_FORK
190 | #define NO_REDIRECTOR
191 | #endif
192 |
193 | #include "mingw.h"
194 |
195 | #include "ftsimport.h"
196 | #include "atom.h"
197 | #include "util.h"
198 | #include "config.h"
199 | #include "event.h"
200 | #include "io.h"
201 | #include "socks.h"
202 | #include "chunk.h"
203 | #include "object.h"
204 | #include "dns.h"
205 | #include "http.h"
206 | #include "client.h"
207 | #include "local.h"
208 | #include "diskcache.h"
209 | #include "server.h"
210 | #include "http_parse.h"
211 | #include "parse_time.h"
212 | #include "forbidden.h"
213 | #include "log.h"
214 | #include "auth.h"
215 | #include "tunnel.h"
216 |
217 | extern AtomPtr configFile;
218 | extern int daemonise;
219 | extern AtomPtr pidFile;
220 |
--------------------------------------------------------------------------------
/Frameworks/polipo-20091115/polipo.man:
--------------------------------------------------------------------------------
1 | .TH POLIPO 1
2 | .SH NAME
3 | polipo \- a caching web proxy
4 | .SH SYNOPSIS
5 | .B polipo
6 | [
7 | .B \-h
8 | |
9 | .B \-v
10 | |
11 | .B \-x
12 | ] [
13 | .B \-c
14 | .I config
15 | ] [
16 | .IB var=val
17 | ]...
18 | .SH DESCRIPTION
19 | Polipo is a caching HTTP proxy. It listens to requests for web pages
20 | from your browser and forwards them to web servers, and forwards the
21 | servers' replies to your browser. In the process, it optimises and
22 | cleans up the network traffic.
23 | .PP
24 | By default, Polipo listens on TCP port 8123. Please configure your
25 | web browser to use the proxy on
26 | .B localhost
27 | port 8123.
28 | .SH OPTIONS
29 | .TP
30 | .B \-h
31 | Display help and exit.
32 | .TP
33 | .B \-v
34 | Display the list of configuration variables and exit.
35 | .TP
36 | .B \-x
37 | Purge the on-disk cache and exit.
38 | .TP
39 | .B \-c
40 | Select an alternate configuration file.
41 | .TP
42 | .IB var = val
43 | Change the value of a configuration variable.
44 | .SH FILES
45 | .TP
46 | .B /etc/polipo/config
47 | The default location of Polipo's configuration file.
48 | .TP
49 | .B /etc/polipo/forbidden
50 | The default location of the list of forbidden URLs.
51 | .TP
52 | .B /var/cache/polipo/
53 | The default location of the on-disk cache.
54 | .TP
55 | .B /usr/share/polipo/www/
56 | The default root of the local web space.
57 | .SH SIGNALS
58 | .TP
59 | .B SIGUSR1
60 | write out all in-memory objects to disk and reload the forbidden URLs file.
61 | .TP
62 | .B SIGUSR2
63 | write out all in-memory objects to disk, discard all in-memory
64 | objects, and reload the forbidden URLs file.
65 | .TP
66 | .B SIGTERM, SIGINT, SIGHUP
67 | write out all in-memory objects to disk and quit.
68 | .SH SECURITY
69 | The internal web server will follow symbolic links that point outside
70 | the local document tree. You should run Polipo in a chroot jail if that
71 | is a problem.
72 | .PP
73 | There is no reason to run Polipo as root.
74 | .SH FULL DOCUMENTATION
75 | The full manual for Polipo is maintained in a texinfo file, and is
76 | normally available through a web server internal to Polipo. Please
77 | make sure that Polipo is running, and point your favourite web browser
78 | at
79 | .IP
80 | http://localhost:8123/
81 | .PP
82 | Alternatively, you may type
83 | .IP
84 | $ info polipo
85 | .PP
86 | at a shell prompt, or
87 | .IP
88 | C-h i m polipo RET
89 | .PP
90 | in
91 | .BR Emacs .
92 | .SH AUTHOR
93 | Polipo was written by Juliusz Chroboczek.
94 |
--------------------------------------------------------------------------------
/Frameworks/polipo-20091115/server.h:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (c) 2003-2006 by Juliusz Chroboczek
3 |
4 | Permission is hereby granted, free of charge, to any person obtaining a copy
5 | of this software and associated documentation files (the "Software"), to deal
6 | in the Software without restriction, including without limitation the rights
7 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | copies of the Software, and to permit persons to whom the Software is
9 | furnished to do so, subject to the following conditions:
10 |
11 | The above copyright notice and this permission notice shall be included in
12 | all copies or substantial portions of the Software.
13 |
14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 | THE SOFTWARE.
21 | */
22 |
23 | extern int serverExpireTime, dontCacheRedirects;
24 |
25 | typedef struct _HTTPServer {
26 | char *name;
27 | int port;
28 | int addrindex;
29 | int isProxy;
30 | int version;
31 | int persistent;
32 | int pipeline;
33 | int lies;
34 | int rtt;
35 | int rate;
36 | time_t time;
37 | int numslots;
38 | int maxslots;
39 | HTTPConnectionPtr *connection;
40 | FdEventHandlerPtr *idleHandler;
41 | HTTPRequestPtr request, request_last;
42 | struct _HTTPServer *next;
43 | } HTTPServerRec, *HTTPServerPtr;
44 |
45 | extern AtomPtr parentHost;
46 | extern int parentPort;
47 |
48 | void preinitServer(void);
49 | void initServer(void);
50 |
51 | void httpServerAbortHandler(ObjectPtr object);
52 | int httpMakeServerRequest(char *name, int port, ObjectPtr object,
53 | int method, int from, int to,
54 | HTTPRequestPtr requestor);
55 | int httpServerQueueRequest(HTTPServerPtr server, HTTPRequestPtr request);
56 | int httpServerTrigger(HTTPServerPtr server);
57 | int httpServerSideRequest(HTTPServerPtr server);
58 | int httpServerDoSide(HTTPConnectionPtr connection);
59 | int httpServerSideHandler(int status,
60 | FdEventHandlerPtr event,
61 | StreamRequestPtr srequest);
62 | int httpServerSideHandler2(int status,
63 | FdEventHandlerPtr event,
64 | StreamRequestPtr srequest);
65 | int httpServerConnectionDnsHandler(int status,
66 | GethostbynameRequestPtr request);
67 | int httpServerConnectionHandler(int status,
68 | FdEventHandlerPtr event,
69 | ConnectRequestPtr request);
70 | int httpServerSocksHandler(int status, SocksRequestPtr request);
71 | int httpServerConnectionHandlerCommon(int status,
72 | HTTPConnectionPtr connection);
73 | void httpServerFinish(HTTPConnectionPtr connection, int s, int offset);
74 |
75 | void httpServerReply(HTTPConnectionPtr connection, int immediate);
76 | void httpServerAbort(HTTPConnectionPtr connection, int, int, struct _Atom *);
77 | void httpServerAbortRequest(HTTPRequestPtr request, int, int, struct _Atom *);
78 | void httpServerClientReset(HTTPRequestPtr request);
79 | void httpServerUnpipeline(HTTPRequestPtr request);
80 | int
81 | httpServerSendRequest(HTTPConnectionPtr connection);
82 | int
83 | httpServerHandler(int status,
84 | FdEventHandlerPtr event,
85 | StreamRequestPtr request);
86 | int
87 | httpServerReplyHandler(int status,
88 | FdEventHandlerPtr event,
89 | StreamRequestPtr request);
90 | int
91 | httpServerIndirectHandler(int status,
92 | FdEventHandlerPtr event,
93 | StreamRequestPtr request);
94 | int
95 | httpServerDirectHandler(int status,
96 | FdEventHandlerPtr event,
97 | StreamRequestPtr request);
98 | int
99 | httpServerDirectHandler2(int status,
100 | FdEventHandlerPtr event,
101 | StreamRequestPtr request);
102 | int httpServerRequest(ObjectPtr object, int method, int from, int to,
103 | HTTPRequestPtr, void*);
104 | int httpServerHandlerHeaders(int eof,
105 | FdEventHandlerPtr event,
106 | StreamRequestPtr request,
107 | HTTPConnectionPtr connection);
108 | int httpServerReadData(HTTPConnectionPtr, int);
109 | int connectionAddData(HTTPConnectionPtr connection, int skip);
110 | int
111 | httpWriteRequest(HTTPConnectionPtr connection, HTTPRequestPtr request, int);
112 |
113 | void listServers(FILE*);
114 |
--------------------------------------------------------------------------------
/Frameworks/polipo-20091115/socks.h:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (c) 2003-2006 by Juliusz Chroboczek
3 |
4 | Permission is hereby granted, free of charge, to any person obtaining a copy
5 | of this software and associated documentation files (the "Software"), to deal
6 | in the Software without restriction, including without limitation the rights
7 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | copies of the Software, and to permit persons to whom the Software is
9 | furnished to do so, subject to the following conditions:
10 |
11 | The above copyright notice and this permission notice shall be included in
12 | all copies or substantial portions of the Software.
13 |
14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 | THE SOFTWARE.
21 | */
22 |
23 | extern AtomPtr socksParentProxy;
24 |
25 | typedef struct _SocksRequest {
26 | AtomPtr name;
27 | int port;
28 | int fd;
29 | int (*handler)(int, struct _SocksRequest*);
30 | char *buf;
31 | void *data;
32 | } SocksRequestRec, *SocksRequestPtr;
33 |
34 | void preinitSocks(void);
35 | void initSocks(void);
36 | int do_socks_connect(char*, int, int (*)(int, SocksRequestPtr), void*);
37 |
--------------------------------------------------------------------------------
/Frameworks/polipo-20091115/tunnel.h:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (c) 2004-2006 by Juliusz Chroboczek
3 |
4 | Permission is hereby granted, free of charge, to any person obtaining a copy
5 | of this software and associated documentation files (the "Software"), to deal
6 | in the Software without restriction, including without limitation the rights
7 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | copies of the Software, and to permit persons to whom the Software is
9 | furnished to do so, subject to the following conditions:
10 |
11 | The above copyright notice and this permission notice shall be included in
12 | all copies or substantial portions of the Software.
13 |
14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 | THE SOFTWARE.
21 | */
22 |
23 | typedef struct _CircularBuffer {
24 | int head;
25 | int tail;
26 | char *buf;
27 | } CircularBufferRec, *CircularBufferPtr;
28 |
29 | #define TUNNEL_READER1 1
30 | #define TUNNEL_WRITER1 2
31 | #define TUNNEL_EOF1 4
32 | #define TUNNEL_EPIPE1 8
33 | #define TUNNEL_READER2 16
34 | #define TUNNEL_WRITER2 32
35 | #define TUNNEL_EOF2 64
36 | #define TUNNEL_EPIPE2 128
37 |
38 | typedef struct _Tunnel {
39 | AtomPtr hostname;
40 | int port;
41 | int flags;
42 | int fd1;
43 | CircularBufferRec buf1;
44 | int fd2;
45 | CircularBufferRec buf2;
46 | } TunnelRec, *TunnelPtr;
47 |
48 | void do_tunnel(int fd, char *buf, int offset, int len, AtomPtr url);
49 |
50 |
51 |
--------------------------------------------------------------------------------
/Frameworks/polipo-20091115/util.h:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (c) 2003-2006 by Juliusz Chroboczek
3 |
4 | Permission is hereby granted, free of charge, to any person obtaining a copy
5 | of this software and associated documentation files (the "Software"), to deal
6 | in the Software without restriction, including without limitation the rights
7 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | copies of the Software, and to permit persons to whom the Software is
9 | furnished to do so, subject to the following conditions:
10 |
11 | The above copyright notice and this permission notice shall be included in
12 | all copies or substantial portions of the Software.
13 |
14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 | THE SOFTWARE.
21 | */
22 |
23 | /* These are Polipo's error codes. They need to be positive integers,
24 | and must not collide with possible errno values.
25 | Starting at 2^16 should be safe enough. */
26 |
27 | #define E0 (1 << 16)
28 | #define E1 (2 << 16)
29 | #define E2 (3 << 16)
30 | #define E3 (4 << 16)
31 | #define EUNKNOWN (E0)
32 | #define EDOSHUTDOWN (E0 + 1)
33 | #define EDOGRACEFUL (E0 + 2)
34 | #define EDOTIMEOUT (E0 + 3)
35 | #define ECLIENTRESET (E0 + 4)
36 | #define ESYNTAX (E0 + 5)
37 | #define EREDIRECTOR (E0 + 6)
38 | #define EDNS_HOST_NOT_FOUND (E1)
39 | #define EDNS_NO_ADDRESS (E1 + 1)
40 | #define EDNS_NO_RECOVERY (E1 + 2)
41 | #define EDNS_TRY_AGAIN (E1 + 3)
42 | #define EDNS_INVALID (E1 + 4)
43 | #define EDNS_UNSUPPORTED (E1 + 5)
44 | #define EDNS_FORMAT (E1 + 6)
45 | #define EDNS_REFUSED (E1 + 7)
46 | #define EDNS_CNAME_LOOP (E1 + 8)
47 | #define ESOCKS_PROTOCOL (E2)
48 | /* These correspond to SOCKS status codes 91 through 93 */
49 | #define ESOCKS_REJECT_FAIL (E2 + 1)
50 | #define ESOCKS_REJECT_IDENTD (E2 + 2)
51 | #define ESOCKS_REJECT_UID_MISMATCH (E2 + 3)
52 | /* (ESOCKS5_BASE + n) corresponds to SOCKS5 status code n (0 to 8) */
53 | #define ESOCKS5_BASE (E3)
54 |
55 | typedef struct _IntRange {
56 | int from;
57 | int to;
58 | } IntRangeRec, *IntRangePtr;
59 |
60 | typedef struct _IntList {
61 | int length;
62 | int size;
63 | IntRangePtr ranges;
64 | } IntListRec, *IntListPtr;
65 |
66 | char *strdup_n(const char *restrict buf, int n) ATTRIBUTE ((malloc));
67 | int snnprintf(char *restrict buf, int n, int len, const char *format, ...)
68 | ATTRIBUTE ((format (printf, 4, 5)));
69 | int snnvprintf(char *restrict buf, int n, int len, const char *format, va_list args)
70 | ATTRIBUTE ((format (printf, 4, 0)));
71 | int snnprint_n(char *restrict buf, int n, int len, const char *s, int slen);
72 | int strcmp_n(const char *string, const char *buf, int n) ATTRIBUTE ((pure));
73 | int digit(char) ATTRIBUTE ((const));
74 | int letter(char) ATTRIBUTE ((const));
75 | char lwr(char) ATTRIBUTE ((const));
76 | char* lwrcpy(char *restrict dst, const char *restrict src, int n);
77 | int lwrcmp(const char *as, const char *bs, int n) ATTRIBUTE ((pure));
78 | int strcasecmp_n(const char *string, const char *buf, int n)
79 | ATTRIBUTE ((pure));
80 | int atoi_n(const char *restrict string, int n, int len, int *value_return);
81 | int isWhitespace(const char *string) ATTRIBUTE((pure));
82 | #ifndef HAVE_MEMRCHR
83 | void *memrchr(const void *s, int c, size_t n) ATTRIBUTE ((pure));
84 | #endif
85 | int h2i(char h) ATTRIBUTE ((const));
86 | char i2h(int i) ATTRIBUTE ((const));
87 | int log2_floor(int x) ATTRIBUTE ((const));
88 | int log2_ceil(int x) ATTRIBUTE ((const));
89 | char* vsprintf_a(const char *f, va_list args)
90 | ATTRIBUTE ((malloc, format (printf, 1, 0)));
91 | char* sprintf_a(const char *f, ...)
92 | ATTRIBUTE ((malloc, format (printf, 1, 2)));
93 | unsigned int hash(unsigned seed, const void *restrict key, int key_size,
94 | unsigned int hash_size)
95 | ATTRIBUTE ((pure));
96 | char *pstrerror(int e);
97 | time_t mktime_gmt(struct tm *tm) ATTRIBUTE ((pure));
98 | AtomPtr expandTilde(AtomPtr filename);
99 | void do_daemonise(int noclose);
100 | void writePid(char *pidfile);
101 | int b64cpy(char *restrict dst, const char *restrict src, int n, int fss);
102 | int b64cmp(const char *restrict a, int an, const char *restrict b, int bn)
103 | ATTRIBUTE ((pure));
104 | IntListPtr makeIntList(int size) ATTRIBUTE ((malloc));
105 | void destroyIntList(IntListPtr list);
106 | int intListMember(int n, IntListPtr list) ATTRIBUTE ((pure));
107 | int intListCons(int from, int to, IntListPtr list);
108 | int physicalMemory(void);
109 |
--------------------------------------------------------------------------------
/Frameworks/srelay-0.4.7p3/Changes:
--------------------------------------------------------------------------------
1 | #
2 | # Changes
3 | # $Id: Changes,v 1.15 2009/12/17 14:49:50 bulkstream Exp $
4 | #
5 | 0.4.7p3 (2009/12/17)
6 | + can set the version of Next Hop socks in config.
7 | + tcp_wrapper is enabled with -w command line option (disabled by default).
8 | 0.4.7p2 (2009/12/17)
9 | + socks5 auth method nego with next-hop be more appropriate.
10 | (will not use user/pass when -u option wasn't specified.)
11 | 0.4.7p1 (2009/12/09)
12 | + fix socks.c for DEEP forward.
13 | + some manpage descriptions added.
14 | 0.4.7 (2009/12/09)
15 |
16 | 0.4.7b5 (2009/12/08)
17 | + added DEEP forward (undocumented.)
18 | 0.4.7b4 (2009/12/07)
19 | + re-construct struct socks_req
20 | + rewrite socks.c for future develop.
21 | 0.4.7b3 (2009/12/01)
22 | + fix bug. socks fqdn proxy relaying was not working.
23 | (Thanks Markus Ferlitsch.)
24 | 0.4.7b (2009/08/30) Yeah! 6 year and more had passed.
25 | + added feature of using same outgoing ip as incoming(-g)
26 | (Thanks Comrade. testing will be needed.)
27 | + fix compile errors on MacOSX for my own environment was shifted to it.
28 |
29 | 0.4.6a (2003/04/22)
30 | + bug fix - avoid compile error (may be) on Linux. (Thanks Michal.)
31 | + adopt for more recent configure MACROs.
32 |
33 | 0.4.6 (2003/04/13)
34 | + bug fix
35 |
36 | 0.4.5c (2003/04/10)
37 | + Enabling Solaris 2.6/8 compilations. but not tested well :-p
38 | + Add v6defs.h mainly for Solaris 2.6
39 | + Add INSTALL file
40 |
41 | 0.4.5a (2003/03/31)
42 | + Bug Fix ... address masks, address compare, etc.
43 | + TODO:
44 | IPv6 site-local address consideration(scope id).
45 |
46 | 0.4.5 (2003/03/27) - alpha to beta quality
47 | + Almost all rewritten to support IPv6
48 | + TODO:
49 | SOCKS-BIND in IPv6 not implemented yet.
50 | Solaris 2.6 support has gone for a while.
51 | Solaris 8 support will be done for a while.
52 | Connection Loop detection.
53 | Bug Fix (may be :-p)
54 |
55 | 0.4.0a (2003/01/16)
56 | + remove unsed struct thread_tab.
57 | + remove unsed argument of serv_loop().
58 | + set signal behaviors more properly.
59 |
60 | 0.4.0 (2003/01/06)
61 | + Ported to Linux (kernel 2.4.20/glibc-2.2.93-5 RedHat 8.0)
62 | ... this needs a lot more testing ...
63 | + Fixed against compile warnings/errors on Linux gcc.
64 | + Renew autoconf and its source configure.in, etc.
65 | acconfig.h
66 | - removed
67 | configure.in
68 | + Added acconfig.h contents.
69 | + Modified LINUX related checkings.
70 | srelay.h
71 | get-bind.c
72 | + Added code for getting Linux routing table.
73 |
74 | 0.3.3 (2003/01/02)
75 | relay.c
76 | + Bugfix
77 | Thread mode srelay consumes CPU nearly 100% on FreeBSD 4.7
78 | and Solaris 8. rfds/xfds in relay() could be polluted by
79 | something I could not make out.
80 | init.c
81 | main.c
82 | util.c
83 | relay.c
84 | srelay.h
85 | + Added child process control
86 | Child process control for Fork mode was full of imcompleteness.
87 |
88 | 0.3.2 (2002/12/06)
89 | + Bugfix
90 | UDP associate request(which is not yet implemented;-) triggers
91 | service unavailable entirely.
92 | socks.c
93 | auth-pwd.c
94 | srelay.h
95 | timerd_read()
96 | * Added parameter 'flags'. will be passed to recvfrom() directly.
97 | wait_for_read()
98 | * Added check FD_ISSET().
99 | + Added CVS Id line.
100 |
101 | 0.3.1 (2002/08/16)
102 | main.c
103 | main()
104 | * forcing allocate the file descriptor 0/1/2 to /dev/null.
105 |
106 | relay.c
107 | readn()
108 | writen()
109 | forward()
110 | * reduce settimer() call. saving CPU usage.
111 |
112 | 0.3 (2002/06/14)
113 | auth-pwd.c
114 | auth_pwd_server()
115 | * log format
116 | * make sure to cleanup username password storage.
117 |
118 | init.c
119 | relay.c
120 | global array str_serv_sock added.
121 | which is used in tcp_wrapper's validation control.
122 | this array holds strings formed
123 | nnn.nnn.nnn.nnn.ppppp
124 | where nnn.... is IP address and ppppp is a port number.
125 | this corresponds srelay server's listen socket, i.e. arguments
126 | of 'i' option. this string can be used as "daemon list" of
127 | tcp_wrappers hosts_access(5) file.
128 | when you started srelay
129 |
130 | # srelay -i 123.223.100.10
131 |
132 | you can put in 'hosts.allow' like,
133 |
134 | 123.223.100.10.1080: my.domain.com 123.223.100.
135 |
136 | with no 'i' option,
137 |
138 | 0.0.0.0.1080: 123.123.123.
139 |
140 | will be evaluated. in any case, the daemon list 'srelay' can
141 |
142 | be evaluated as whole daemon sockets of srelay.
143 |
144 | relay.c
145 | relay()
146 | change some codes for collecting informations of transfer state
147 | logging.
148 |
149 | main.c
150 | socks.c
151 | command line '-b' option added.
152 | this indicates SOCKS BIND sockets port restriction off.
153 | the port restriction is impremented in my own way, because the
154 | definition of BIND requested port is quite not sure.
155 |
156 | RFC1928 says about BIND request's DST.PORT just,
157 |
158 | ... In(It ?) is expected that a SOCKS server will use DST.ADDR
159 | and DST.PORT in evaluating the BIND request.
160 |
161 | and, NEC's draft "draft-ietf-aft-socks-pro-v5-04, 22 February 1999"
162 | (http://www.socks.nec.com/draft/draft-ietf-aft-socks-pro-v5-04.txt)
163 | rewrites here by,
164 |
165 | DST.ADDR must be the address of the primary connection's
166 | destination. DST.PORT should be the requested port (or 0 for a
167 | random, unused port). It is expected that a SOCKS server will
168 | use DST.ADDR and DST.PORT in evaluating the BIND request.
169 |
170 | there are some imprementation that setting this BIND request's
171 | DST.PORT to the same value as primary CONNECTion's requested
172 | DST.PORT. (FFFTP 1.8 etc.)
173 |
174 | my own rule:
175 | BIND port selection priority.
176 | 1. requested port. (assuming dest->sin_port as requested port)
177 | 2. clients src port.
178 | 3. free port.
179 | and, restriction:
180 | if requested port or client's src port is less than
181 | IPPORT_RESERVEDSTART(600), force selecting free port.
182 |
183 | socks.c
184 |
185 | bug fix.
186 | when using username/password auth in socks5 server mode, it was
187 | still usable as socks4 server. this conflicts,
188 | - user needs username/password in socks5
189 | but,
190 | - user doesn't need any authentication in using socks4.
191 | fixed as if the srelay invoked using '-a' option, the socks4
192 | requests are shut-offed.
193 |
194 | readconf.c
195 | readconf()
196 | make function durable in reloading config.
197 |
198 | main.c
199 | util.c
200 | define SIGHUP handler 'reload'. you can reconfigure srelay.conf
201 | (socks relay configuration) with "kill -HUP pid" operation.
202 |
203 | srelay.h
204 | BUFSIZE 2048 -> 8192
205 | a little blessing speed up.
206 |
--------------------------------------------------------------------------------
/Frameworks/srelay-0.4.7p3/INSTALL:
--------------------------------------------------------------------------------
1 | The srelay Installation Tips.
2 | $Id: INSTALL,v 1.4 2009/09/04 08:29:40 bulkstream Exp $
3 |
4 | o How to build and install
5 |
6 | Unpack the source.
7 |
8 | % gzip -dc srelay-X.Y.Z.tar.gz | tar xvf -
9 | % cd srelay-X.Y.Z
10 |
11 | Run configure.
12 | To see configuration options,
13 | % ./configure --help
14 |
15 | Configuration options.
16 | --disable-thread disable pthread feature.
17 | srelay configures to use pthread by default. if you prefer not
18 | to use pthread (to use forking server), disable it.
19 |
20 | --with-libbind[=PATH] to use libbind.
21 | If your system does not have IPv6 compatible name resolving API;
22 | getaddrinfo, getnameinfo,...etc.(e.g. Solaris 2.6), you have to
23 | prepare libbind library prior to configure srelay.
24 | Please See LIBBIND INSTALL.
25 |
26 | --with-libwrap[=PATH|yes|no] with tcp_wrapper access control.
27 | If your system has libwrap, you can use the same access control
28 | base.
29 |
30 | --with-syslog-fac=FACILITY syslog facility (LOG_DAEMON).
31 | Srelay logs through syslog. the default facility is LOG_DAEMON.
32 |
33 | Make
34 | If configure works without any errors, run make.
35 |
36 | % make
37 |
38 | ( currently I have no 'install' target in Makefile. )
39 |
40 | o MacOSX
41 | MacOSX(10.4 or newer) users can setup daemon using Apple's new
42 | launchd mechanism.
43 | After building the srelay binary, put it in appropriate directry.
44 | e.g.)
45 | $cp srelay /usr/local/sbin/.
46 |
47 | then, prepare the file called 'launchd plist'. Example is in
48 | scripts directry, 'local.srelay.plist'.
49 | put this file into
50 | /Library/LaunchDaemons/.
51 |
52 | you should not put it into /System/Library/LaunchDaemons.
53 | Try these command and see ps or syslog output. launchd errors are
54 | reported in /var/log/system.log. srelay's errors are syslog
55 | daemon.* facility by default. please check your syslog.conf setting.
56 |
57 | $ cd /Library/LaunchDaemons
58 | $ launchctl load -F local.srelay.plist
59 |
60 | Sample plist file disables start up by default.
61 | '-F' option ignores this property and 'force' start up
62 | the daemon.
63 | If some running test being well, and if you would
64 | like the daemon starts at the system start up,
65 | reload the plist like,
66 |
67 | $ launchctl unload local.srelay.plist
68 | $ launchctl load -w local.srelay.plist
69 |
70 |
71 | o Solaris 10
72 | Solaris 10 has SMF to control system start up daemons. you can
73 | setup srelay as service (daemon) under control of this facility.
74 |
75 | copy a file from scripts directory to appropriate place.
76 | # cp scripts/svc-srelay /lib/svc/method/.
77 |
78 | svc-srelay is just a start up shell and called from SMF.
79 | type svccfg command to register the service.
80 | # svccfg import scripts/srelay.xml
81 |
82 | srelay.xml is a sample SMF service manifest description (may be).
83 |
84 | if no error, srelay process should be seen in ps result.
85 | Log outputs are syslog daemon.* facility.
86 |
87 | daemon stop/start operations.
88 | start srelay
89 | # svcadm enable network/srelay
90 | stop srelay
91 | # svcadm disable network/srelay
92 |
93 | unregister from SMF
94 | # svcadm disable network/srelay
95 | # svccfg delete network/srelay
96 |
97 | o FreeBSD
98 | scripts/srelay.sh is a sample startup script for FreeBSD.
99 | don't forget setting srelay_enable="Yes" to rc.conf. Or you
100 | can avoid this check comment out or removing
101 | rcvar=`set_rcvar`
102 | line.
103 |
104 | o Linux
105 | scripts/rc.srelay is a sample for Linux. you can register
106 | srelay as 'srelay' service,
107 | # cp rc.srelay /etc/init.d/srelay
108 | # cd /etc/init.d
109 | # chkconfig --add srelay
110 | starting service,
111 | # /sbin/service srelay start
112 | stopping service,
113 | # /sbin/service srelay stop
114 |
115 | unregister it,
116 | # chkconfig --del srelay
117 |
118 |
119 | o LIBBIND INSTALL
120 | (currently not tested. you may not need unless using ancient OSs
121 | nor try running on arduino ;-)
122 |
123 | To install libbind, you have to get source code from outside this
124 | package. ISC libbind may be handy for it.
125 | Or, You could have installed BIND with its libraries, please check
126 | the installation pathes of BIND before these steps.
127 |
128 | To get ISC libbind source, see
129 | https://www.isc.org/software/libbind
130 | and fetch/wget, etc.
131 | ftp://ftp.isc.org/isc/libbind/6.0/libbind-6.0.tar.gz
132 |
133 | And, build.
134 | % gzip -dc libbind-6.0.tar.gz | tar xvf -
135 | % cd libbind-6.0
136 | % ./configure
137 | % make
138 | % make DESTDIR=/path/to/temp install
139 |
140 | check the includes and libbind.a are there in
141 | /path/to/temp/usr/local/bind/inclue
142 | /path/to/temp/usr/local/lib
143 |
144 | Then, you can configure the srelay.
145 | % cd /path/of/srelay-X.Y.Z
146 | % env LIBS="-L/path/to/temp/usr/local/lib" \
147 | ./configure --with-libbind=/path/to/temp/usr/local/bind
148 | % make
149 |
--------------------------------------------------------------------------------
/Frameworks/srelay-0.4.7p3/Makefile.in:
--------------------------------------------------------------------------------
1 | #
2 | # Makefile
3 | # $Id: Makefile.in,v 1.6 2009/12/08 08:38:38 bulkstream Exp $
4 | #
5 |
6 | SHELL = /bin/sh
7 | prefix = @prefix@
8 | exec_prefix=@exec_prefix@
9 | srcdir = @srcdir@
10 | sbindir = @sbindir@
11 | libdir = @libdir@
12 | sysconfdir = @sysconfdir@
13 | CC = @CC@
14 | CFLAGS = @CFLAGS@
15 | CPPFLAGS= @CPPFLAGS@
16 | DEFS = @DEFS@ -DSYSCONFDIR=\"$(sysconfdir)\"
17 | LDFLAGS = @LDFLAGS@
18 | LIBS = @LIBS@
19 | INCLUDES=
20 | OBJS = init.o readconf.o util.o socks.o relay.o main.o \
21 | auth-pwd.o get-bind.o
22 | TARGET = srelay
23 |
24 | .c.o:
25 | $(CC) -I. $(CPPFLAGS) $(DEFS) $(CFLAGS) -c $<
26 |
27 | all: $(TARGET)
28 |
29 | $(TARGET): $(OBJS)
30 | $(CC) $(OBJS) $(LIBS) $(LDFLAGS) -o $@
31 |
32 | srelay.h: $(INCLUDES)
33 | @touch $@
34 |
35 | clean:
36 | rm -f *.o *~ *.core core ktrace.out
37 |
38 | distclean: clean
39 | rm -f $(TARGET)
40 | rm -f config.log config.status config.cache Makefile config.h
41 | rm -f *.orig *.rej
42 | rm -rf configure.lineno autom4te*.cache
43 | rm -f readconf
44 |
45 | init.o: init.c srelay.h
46 | readconf.o: readconf.c srelay.h
47 | util.o: util.c srelay.h
48 | socks.o: socks.c srelay.h
49 | relay.o: relay.c srelay.h
50 | main.o: main.c srelay.h
51 | auth-pwd.o: auth-pwd.c srelay.h
52 | get-bind.o: get-bind.c srelay.h
53 |
--------------------------------------------------------------------------------
/Frameworks/srelay-0.4.7p3/config.h.in:
--------------------------------------------------------------------------------
1 | /* config.h.in. Generated from configure.in by autoheader. */
2 |
3 | /* Define if the build system is FreeBSD */
4 | #undef FREEBSD
5 |
6 | /* Define to 1 if you have the header file. */
7 | #undef HAVE_FCNTL_H
8 |
9 | /* Define to 1 if you have the `freeaddrinfo' function. */
10 | #undef HAVE_FREEADDRINFO
11 |
12 | /* Define to 1 if you have the `getaddrinfo' function. */
13 | #undef HAVE_GETADDRINFO
14 |
15 | /* Define to 1 if you have the `getnameinfo' function. */
16 | #undef HAVE_GETNAMEINFO
17 |
18 | /* Define to 1 if you have the header file. */
19 | #undef HAVE_INTTYPES_H
20 |
21 | /* Define to 1 if you have the `bind' library (-lbind). */
22 | #undef HAVE_LIBBIND
23 |
24 | /* Define to 1 if you have the `bind_r' library (-lbind_r). */
25 | #undef HAVE_LIBBIND_R
26 |
27 | /* Define to 1 if you have the `crypt' library (-lcrypt). */
28 | #undef HAVE_LIBCRYPT
29 |
30 | /* Define to 1 if you have the `nsl' library (-lnsl). */
31 | #undef HAVE_LIBNSL
32 |
33 | /* Define to 1 if you have the `socket' library (-lsocket). */
34 | #undef HAVE_LIBSOCKET
35 |
36 | /* Define to 1 if you have the `wrap' library (-lwrap). */
37 | #undef HAVE_LIBWRAP
38 |
39 | /* Define to 1 if you have the `xnet' library (-lxnet). */
40 | #undef HAVE_LIBXNET
41 |
42 | /* Define if you have the header file. */
43 | #undef HAVE_LIMITS_H
44 |
45 | /* Define to 1 if you have the header file. */
46 | #undef HAVE_MEMORY_H
47 |
48 | /* Define to 1 if you have the `select' function. */
49 | #undef HAVE_SELECT
50 |
51 | /* Define if you have the sockaddr_dl structure. */
52 | #undef HAVE_SOCKADDR_DL_STRUCT
53 |
54 | /* Define if `sa_len' is member of `struct sockaddr'. */
55 | #undef HAVE_SOCKADDR_SA_LEN
56 |
57 | /* Define to 1 if you have the `socket' function. */
58 | #undef HAVE_SOCKET
59 |
60 | /* Define to 1 if the system has the type `socklen_t'. */
61 | #undef HAVE_SOCKLEN_T
62 |
63 | /* Define to 1 if you have the header file. */
64 | #undef HAVE_STDINT_H
65 |
66 | /* Define to 1 if you have the header file. */
67 | #undef HAVE_STDLIB_H
68 |
69 | /* Define to 1 if you have the header file. */
70 | #undef HAVE_STRINGS_H
71 |
72 | /* Define to 1 if you have the header file. */
73 | #undef HAVE_STRING_H
74 |
75 | /* Define to 1 if you have the header file. */
76 | #undef HAVE_SYSLOG_H
77 |
78 | /* Define to 1 if you have the header file. */
79 | #undef HAVE_SYS_RESOURCE_H
80 |
81 | /* Define to 1 if you have the header file. */
82 | #undef HAVE_SYS_STAT_H
83 |
84 | /* Define to 1 if you have the header file. */
85 | #undef HAVE_SYS_TIME_H
86 |
87 | /* Define to 1 if you have the header file. */
88 | #undef HAVE_SYS_TYPES_H
89 |
90 | /* Define to 1 if you have that is POSIX.1 compatible. */
91 | #undef HAVE_SYS_WAIT_H
92 |
93 | /* Define if you have the header file. */
94 | #undef HAVE_TCPD_H
95 |
96 | /* Define to 1 if the system has the type `uint16_t'. */
97 | #undef HAVE_UINT16_T
98 |
99 | /* Define to 1 if the system has the type `uint32_t'. */
100 | #undef HAVE_UINT32_T
101 |
102 | /* Define to 1 if the system has the type `uint8_t'. */
103 | #undef HAVE_UINT8_T
104 |
105 | /* Define to 1 if you have the header file. */
106 | #undef HAVE_UNISTD_H
107 |
108 | /* Define to 1 if the system has the type `u_int16_t'. */
109 | #undef HAVE_U_INT16_T
110 |
111 | /* Define to 1 if the system has the type `u_int32_t'. */
112 | #undef HAVE_U_INT32_T
113 |
114 | /* Define to 1 if the system has the type `u_int8_t'. */
115 | #undef HAVE_U_INT8_T
116 |
117 | /* Define if the build system is Linux */
118 | #undef LINUX
119 |
120 | /* Define if you indicate LOG_LOCALx syslog facility. */
121 | #undef LOCAL_FAC
122 |
123 | /* Define if the build system is MacOSX */
124 | #undef MACOSX
125 |
126 | /* Define to the address where bug reports for this package should be sent. */
127 | #undef PACKAGE_BUGREPORT
128 |
129 | /* Define to the full name of this package. */
130 | #undef PACKAGE_NAME
131 |
132 | /* Define to the full name and version of this package. */
133 | #undef PACKAGE_STRING
134 |
135 | /* Define to the one symbol short name of this package. */
136 | #undef PACKAGE_TARNAME
137 |
138 | /* Define to the version of this package. */
139 | #undef PACKAGE_VERSION
140 |
141 | /* Define as the return type of signal handlers (`int' or `void'). */
142 | #undef RETSIGTYPE
143 |
144 | /* Define if the build system is Solaris */
145 | #undef SOLARIS
146 |
147 | /* Define to 1 if you have the ANSI C header files. */
148 | #undef STDC_HEADERS
149 |
150 | /* Define if you indicate your favor syslog facility. */
151 | #undef SYSLOG_FAC
152 |
153 | /* Define to 1 if you can safely include both and . */
154 | #undef TIME_WITH_SYS_TIME
155 |
156 | /* Define if you build a POSIX threading version. */
157 | #undef USE_THREAD
158 |
--------------------------------------------------------------------------------
/Frameworks/srelay-0.4.7p3/configure.in:
--------------------------------------------------------------------------------
1 | dnl Process this file with autoconf to produce a configure script.
2 | dnl $Id: configure.in,v 1.8 2009/08/30 13:06:32 bulkstream Exp $
3 | AC_INIT(main.c)
4 | AC_CONFIG_HEADER(config.h)
5 | AC_CANONICAL_TARGET
6 |
7 | case "$build_os" in
8 | freebsd*)
9 | OS=FREEBSD
10 | AC_DEFINE(FREEBSD)
11 | ;;
12 | solaris*)
13 | OS=SOLARIS
14 | AC_DEFINE(SOLARIS)
15 | ;;
16 | linux*)
17 | case "$build_cpu" in
18 | i*86)
19 | OS=LINUX
20 | AC_DEFINE(LINUX)
21 | ;;
22 | esac
23 | ;;
24 | darwin*)
25 | OS=MACOSX
26 | AC_DEFINE(MACOSX)
27 | ;;
28 | esac
29 |
30 | CFLAGS="$CFLAGS -O2 -Wall"
31 | dnl LDFLAGS="$LDFLAGS -s"
32 |
33 | dnl Local libralies.
34 | if test -d /usr/local/lib; then
35 | LIBS="-L/usr/local/lib $LIBS"
36 | fi
37 |
38 | dnl Solaris 2.6 depends libbind.
39 | dnl libbind default installation base directory.
40 | LIBBIND="/usr/local/bind"
41 |
42 | dnl Checks for programs.
43 | GCC=yes
44 | AC_PROG_CC
45 |
46 |
47 | #dnl Checks for libraries.
48 |
49 | AC_ARG_WITH(libbind,
50 | [ --with-libbind[[=PATH]] to use libbind.],
51 | libbind="$withval",
52 | libbind="no")
53 | if test "$libbind" = "yes"; then
54 | if test -d "$LIBBIND/include"; then
55 | CFLAGS="-I$LIBBIND/include $CFLAGS"
56 | fi
57 | elif test "$libbind" != "no"; then
58 | if test -d "$libbind"/lib; then
59 | LIBS="-L${libbind}/lib $LIBS"
60 | fi
61 | if test -d "$libbind"/include; then
62 | CFLAGS="-I${libbind}/include $CFLAGS"
63 | fi
64 | fi
65 |
66 | if test "$OS" = "SOLARIS"; then
67 | if test "$libbind" = "no"; then
68 | AC_CHECK_LIB(socket, socket)
69 | else
70 | AC_CHECK_LIB(xnet, socket)
71 | fi
72 | AC_CHECK_LIB(nsl, getaddrinfo,,
73 | if test "$libbind" != "no"; then
74 | AC_CHECK_LIB(bind_r, getaddrinfo,,
75 | AC_CHECK_LIB(bind, getaddrinfo,,
76 | AC_MSG_ERROR("required functions may not work", -1)))
77 | else
78 | AC_MSG_ERROR("required functions may not work", -1)
79 | fi
80 | )
81 | fi
82 |
83 | AC_ARG_WITH(libwrap,
84 | [ --with-libwrap[[=PATH|yes|no]] with tcp_wrapper access control.],
85 | libwrap="$withval",
86 | libwrap="yes")
87 | if test "$libwrap" != "no"; then
88 | if test "$libwrap" != "yes"; then
89 | if test -d "$libwrap"; then
90 | LIBS="-L$libwrap $LIBS"
91 | fi
92 | fi
93 | AC_CHECK_HEADER(tcpd.h, AC_DEFINE(HAVE_TCPD_H), tcpdh="no")
94 | if test "$tcpdh" != "no"; then
95 | # if test "$OS" = "LINUX" -o "$OS" = "SOLARIS"; then
96 | # AC_MSG_CHECKING([for hosts_ctl in -lwrap])
97 | # saveLIBS="$LIBS"
98 | # LIBS="-lwrap -lnsl $LIBS"
99 | # AC_COMPILE_IFELSE(
100 | # AC_LANG_PROGRAM([
101 | #[int allow_severity;]
102 | #[int deny_severity;]],
103 | #[[hosts_ctl();]]),
104 | # AC_DEFINE(HAVE_LIBWRAP)
105 | # AC_MSG_RESULT([yes]),
106 | # LIBS="$saveLIBS"
107 | # AC_MSG_RESULT([no]))
108 | # else
109 | AC_CHECK_LIB(wrap, hosts_ctl)
110 | # fi
111 | fi
112 | fi
113 |
114 | AC_ARG_WITH(syslog-fac,
115 | [ --with-syslog-fac=FACILITY syslog facility (LOG_DAEMON).],
116 | syslogfac="$withval",
117 | syslogfac="no")
118 | if test "$syslogfac" != "no"; then
119 | if test "$syslogfac" != "yes"; then
120 | AC_MSG_CHECKING([syslog facility is])
121 | AC_MSG_RESULT("$withval")
122 | echo "$withval" |grep "LOG_LOCAL" > /dev/null 2>&1
123 | r=$?
124 | if test $r -eq 0; then
125 | AC_DEFINE_UNQUOTED(LOCAL_FAC, $withval)
126 | else
127 | AC_DEFINE_UNQUOTED(SYSLOG_FAC, $withval)
128 | fi
129 | fi
130 | fi
131 |
132 | AC_ARG_ENABLE(thread,
133 | [ --disable-thread disable pthread feature.],
134 | thread="$enableval",
135 | thread="yes")
136 | if test "$thread" != "no"; then
137 | AC_CHECK_HEADER(pthread.h, header_ok="yes", header_ok="no")
138 | if test "$header_ok" = "yes"; then
139 | AC_MSG_CHECKING([whether enabling thread])
140 | save_CFLAGS="$CFLAGS";
141 | if test "$OS" = "FREEBSD" -o "$OS" = "MACOSX"; then
142 | CFLAGS="$CFLAGS -pthread"
143 | fi
144 | save_LDFLAGS="$LDFLAGS"
145 | if test "$OS" = "FREEBSD" -o "$OS" = "LINUX" -o "$OS" = "MACOSX"; then
146 | LDFLAGS="$LDFLAGS -pthread"
147 | elif test "$OS" = "SOLARIS"; then
148 | LDFLAGS="$LDFLAGS -lpthread"
149 | fi
150 | AC_RUN_IFELSE([AC_LANG_SOURCE([
151 | [#include
152 | void
153 | init_routine()
154 | {
155 | return(0);
156 | }
157 | main()
158 | {
159 | pthread_once_t once_control = PTHREAD_ONCE_INIT;
160 | pthread_once(&once_control, &init_routine);
161 | return(0);
162 | }]])],
163 | AC_DEFINE(USE_THREAD) AC_MSG_RESULT([yes]),
164 | CFLAGS="$save_CFLAGS"; LDFLAGS="$save_LDFLAGS"; AC_MSG_RESULT([no])
165 | )
166 | fi
167 | fi
168 |
169 | AC_CHECK_LIB(crypt, crypt)
170 |
171 | dnl Checks for header files.
172 | AC_HEADER_STDC
173 | AC_HEADER_SYS_WAIT
174 | AC_CHECK_HEADERS(fcntl.h sys/time.h limits.h syslog.h unistd.h\
175 | sys/resource.h)
176 |
177 | dnl Checks for typedefs, structures, and compiler characteristics.
178 | AC_CHECK_TYPES(socklen_t,,,
179 | [#include
180 | #include ])
181 |
182 | AC_CHECK_TYPES([u_int8_t, u_int16_t, u_int32_t, uint8_t, uint16_t, uint32_t],,,
183 | [#include
184 | #include ])
185 |
186 | AC_HEADER_TIME
187 |
188 | AC_CHECK_MEMBER(struct sockaddr_dl.sdl_family,
189 | [AC_DEFINE(HAVE_SOCKADDR_DL_STRUCT)],,
190 | [#include
191 | #include ])
192 |
193 | AC_CHECK_MEMBER(struct sockaddr.sa_len,
194 | [AC_DEFINE(HAVE_SOCKADDR_SA_LEN)],,
195 | [#include
196 | #include ])
197 |
198 | dnl Checks for library functions.
199 | AC_TYPE_SIGNAL
200 | AC_CHECK_FUNCS(\
201 | select\
202 | socket\
203 | getaddrinfo\
204 | getnameinfo\
205 | freeaddrinfo\
206 | )
207 |
208 | AC_OUTPUT(Makefile)
209 |
210 | dnl from acconfig.h
211 | AH_TEMPLATE([FREEBSD],
212 | [Define if the build system is FreeBSD])
213 | AH_TEMPLATE([SOLARIS],
214 | [Define if the build system is Solaris])
215 | AH_TEMPLATE([LINUX],
216 | [Define if the build system is Linux])
217 | AH_TEMPLATE([MACOSX],
218 | [Define if the build system is MacOSX])
219 | AH_TEMPLATE([HAVE_LIMITS_H],
220 | [Define if you have the header file.])
221 | AH_TEMPLATE([HAVE_TCPD_H],
222 | [Define if you have the header file.])
223 | AH_TEMPLATE([SYSLOG_FAC],
224 | [Define if you indicate your favor syslog facility.])
225 | AH_TEMPLATE([LOCAL_FAC],
226 | [Define if you indicate LOG_LOCALx syslog facility.])
227 | AH_TEMPLATE([USE_THREAD],
228 | [Define if you build a POSIX threading version.])
229 | AH_TEMPLATE([HAVE_SOCKADDR_DL_STRUCT],
230 | [Define if you have the sockaddr_dl structure.])
231 | AH_TEMPLATE([HAVE_SOCKADDR_SA_LEN],
232 | [Define if `sa_len' is member of `struct sockaddr'.])
233 |
--------------------------------------------------------------------------------
/Frameworks/srelay-0.4.7p3/scripts/local.srelay.plist:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 | Disabled
7 |
8 | Label
9 | local.srelay
10 | Program
11 | /usr/local/sbin/srelay
12 | ProgramArguments
13 |
14 | srelay
15 | -f
16 |
17 | KeepAlive
18 |
19 | RunAtLoad
20 |
21 | WorkingDirectory
22 | /var/empty
23 | StandardOutPath
24 | /dev/null
25 | StandardErrorPath
26 | /dev/null
27 |
28 |
29 |
--------------------------------------------------------------------------------
/Frameworks/srelay-0.4.7p3/scripts/rc.srelay:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | # startup script for srelay
3 | # Tomo.M
4 | # $Id: rc.srelay,v 1.1 2009/09/02 13:41:40 bulkstream Exp $
5 | # chkconfig: 345 99 0
6 | # description: Srelay is a SOCKS proxy.
7 |
8 | # source function library
9 | . /etc/init.d/functions
10 |
11 | RETVAL=0
12 | prog=srelay
13 |
14 | SRELAY=/usr/local/sbin/srelay
15 | CONF_FILE=/usr/local/etc/srelay.conf
16 | LOCK_FILE=/var/lock/subsys/srelay
17 |
18 | function start()
19 | {
20 | echo -n $"Starting ${prog}: "
21 | ${SRELAY} -c ${CONF_FILE} && success || failure
22 | RETVAL=$?
23 | [ ${RETVAL} -eq 0 ] && touch ${LOCK_FILE}
24 | echo
25 | }
26 |
27 | function stop()
28 | {
29 | echo -n $"Stopping ${prog}: "
30 | killproc ${SRELAY} -TERM
31 | RETVAL=$?
32 | [ ${RETVAL} -eq 0 ] && rm -f ${LOCK_FILE}
33 | echo
34 | }
35 |
36 | function restart()
37 | {
38 | stop && sleep 5 && start
39 | }
40 |
41 |
42 | case "$1" in
43 | start)
44 | start
45 | ;;
46 | stop)
47 | stop
48 | ;;
49 | restart|reload)
50 | restart
51 | ;;
52 | condrestart)
53 | [ -f ${LOCK_FILE} ] && restart
54 | ;;
55 | status)
56 | status ${ENMA}
57 | RETVAL=$?
58 | ;;
59 | *)
60 | echo "Usage: ${prog} {start|stop|restart|reload|condrestart|status}"
61 | RETVAL=1
62 | ;;
63 | esac
64 |
65 | exit ${RETVAL}
66 |
67 |
--------------------------------------------------------------------------------
/Frameworks/srelay-0.4.7p3/scripts/srelay.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | # startup script for srelay
3 | # srelay_enable="Yes" in /etc/rc.conf needed for enable.
4 | # $Id: srelay.sh,v 1.1 2009/09/02 13:41:40 bulkstream Exp $
5 | # Tomo.M
6 |
7 | # PROVIDE: srelay
8 | # REQUIRE: DAEMON jail
9 | # BEFORE: LOGIN
10 | # KEYWORD: FreeBSD NetBSD shutdown
11 |
12 | . /etc/rc.subr
13 |
14 | name="srelay"
15 | rcvar=`set_rcvar`
16 | command="/usr/local/sbin/srelay"
17 | pid_file="/var/run/srelay.pid"
18 | start_cmd="start_${name}"
19 | stop_cmd="stop_${name}"
20 |
21 | start_srelay ()
22 | {
23 | #echo -n "Starting ${name}"
24 | if [ -x ${command} ]; then
25 | ${command}
26 | fi
27 | echo "."
28 | }
29 |
30 | stop_srelay ()
31 | {
32 | #echo -n "Stopping ${name}"
33 | if [ -f ${pid_file} ]; then
34 | /bin/kill `cat ${pid_file}`
35 | fi
36 | echo "."
37 | }
38 |
39 | load_rc_config $name
40 | run_rc_command "$1"
41 |
--------------------------------------------------------------------------------
/Frameworks/srelay-0.4.7p3/scripts/srelay.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 | Srelay SOCKS Proxy
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
--------------------------------------------------------------------------------
/Frameworks/srelay-0.4.7p3/scripts/svc-srelay:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | # startup script for srelay
3 | # $Id: svc-srelay,v 1.1 2009/09/02 13:41:40 bulkstream Exp $
4 | # Tomo.M
5 |
6 | name="srelay"
7 | command="/usr/local/sbin/srelay"
8 | pid_file="/var/run/srelay.pid"
9 | start_cmd="start_${name}"
10 | stop_cmd="stop_${name}"
11 |
12 | start_srelay ()
13 | {
14 | #echo -n "Starting ${name}"
15 | if [ -x ${command} ]; then
16 | ${command}
17 | fi
18 | echo "."
19 | }
20 |
21 | stop_srelay ()
22 | {
23 | #echo -n "Stopping ${name}"
24 | if [ -f ${pid_file} ]; then
25 | /bin/kill `cat ${pid_file}`
26 | fi
27 | echo "."
28 | }
29 |
30 | case "$1" in
31 | start)
32 | if [ -x $command ]; then
33 | start_srelay
34 | fi
35 | ;;
36 | stop)
37 | if [ -f $pid_file ]; then
38 | stop_srelay
39 | fi
40 | ;;
41 | restart)
42 | if [ -x $command -a -f $pid_file ]; then
43 | stop_srelay
44 | start_srelay
45 | fi
46 | ;;
47 | *)
48 | echo "Usage: $0 (start|stop|restart)"
49 | ;;
50 | esac
51 |
--------------------------------------------------------------------------------
/Frameworks/srelay-0.4.7p3/srelay.8:
--------------------------------------------------------------------------------
1 | '\"
2 | .\" Copyright (C) 2001-2009, Tomo.M
3 | .\" All Rights Reserved
4 | .\" $Id: srelay.8,v 1.5 2009/12/09 04:07:53 bulkstream Exp $
5 | .TH srelay 8 "27 Mar 2003"
6 | .if n .tr \--
7 | .SH NAME
8 | srelay \- socks protocol server.
9 | .SH SYNOPSIS
10 | .B srelay
11 | .RB [ options ]
12 | .SH DESCRIPTION
13 | The \fBsrelay\fP is socks version 5 server, including version 4 support.
14 | .br
15 | The \fBsrelay\fP has following features.
16 | .br
17 | - socks version 5 connect/bind operation for TCP relaying.
18 | .br
19 | - socks version 4 connect/bind operation, including FQDN extensions.
20 | .br
21 | - series of multiple socks servers relaying with both version 4 and 5 servers.
22 | .br
23 | - support username/password authentication.
24 | .br
25 | - connection control with tcp_wrappers(libwrap).
26 | .br
27 | - support IPv6 as well as IPv4 (hopefully).
28 | .br
29 | - You can build IPv4 <-> IPv6 gateway with the srelay.
30 | .br
31 | - nicely cope(relay) with NEC's SOCKSv5 reference implementation servers.
32 | .br
33 | - Free to use/distribute.
34 | .SH OPTIONS
35 | The options are as follows:
36 | .TP 10
37 | .B \-c \fI file \fP
38 | configuration file.
39 | .TP
40 | .B \-i \fI i/f \fP
41 | Interface, or listening port. See \fBListening Port\fP.
42 | .TP
43 | .B \-m \fI num \fP
44 | Maximum child process for non-threading daemon.
45 | Or, number of thread for threading daemon.
46 | .TP
47 | .B \-o \fI minutes \fP
48 | Idle transfer timeout in minutes. 0(zero) means no timeout(default.)
49 | .TP
50 | .B \-p \fI file \fP
51 | PID file; stores main process or main thread process ID.
52 | .TP
53 | .B \-u \fI file \fP
54 | srelay password file used in intermediate SOCKS5 server.
55 | .TP
56 | .B \-a \fP[n|p]
57 | authentication method.
58 | .RS
59 | .TP
60 | .B n
61 | No Authentication.
62 | .TP
63 | .B p
64 | Username/Password authentication.
65 | .LP
66 | Authentication methods are evaluated in its placing order. If this option is not present, 'No Authentication' method is taken.
67 | .RE
68 | .TP 10
69 | .B \-f
70 | Run foreground. (not tested well :-p)
71 | .TP
72 | .B \-r
73 | Try resolve client ip to name on logging.
74 | .TP
75 | .B \-s
76 | Logging to syslog, even if running foreground.
77 | .TP
78 | .B \-t
79 | Disable threading. (valid in thread-enabled configuration)
80 | .TP
81 | .B \-b
82 | Avoid BIND port restriction.
83 | .TP
84 | .B \-g
85 | Use the same interface for outbound as inbound.
86 | .TP
87 | .B \-v
88 | Show version info.
89 | .TP
90 | .B \-h \-?
91 | Show help.
92 | .SS Listening Port
93 | .PP
94 | Specifing the server listening ports are in following format.
95 | .TP
96 | .B \-i \fI 192.168.1.5 \fP
97 | Single IP spec. If no port number is specified, defaults to 1080/tcp. Server socket will be 192.168.1.5 port 1080.
98 | .TP
99 | .B \-i \fI 192.168.1.5:9999 \fP
100 | Single IP with port. Server socket will be 192.168.1.5 port 9999.
101 | .TP
102 | .B \-i \fI my.socks.host:5432 \fP
103 | Hostname is also accepted.
104 | .TP
105 | .B \-i \fI :1234 \fP
106 | No host IP or hostname is specified. Server socket will be INADDR_ANY port 1234.
107 | .TP
108 | .B \-i \fI '[2003:268:1234:4321:250:8bff:fea8:1234]:1234'
109 | IPv6 address must be surrounded by '[' and ']'. In most of the cases, you have to escape '[' and ']' characters against your shell.
110 | .P
111 | \fB -i \fP options can be appear multiple times if you'd like to have a lot of holes.
112 | .P
113 | If no \fB -i \fP option is specified, default port is \fI INADDR_ANY/INADDR6_ANY port 1080 \fP.
114 | .SS Authentication method
115 | .P
116 | The socks version 5 authentication is mechanism for authenticate the server user.
117 | The \fBsrelay\fP only supports 'No Authentication' and 'Username/Password Authentication'.
118 | On the Username/Password authentication, the \fBsrelay\fP using the server host's account information. For instance, using UNIX host's password database. This is deprecated if you are in the network with full of sniffers :) Why ? er, plain text password is launched by the client every time at connecting the server.
119 | I recommend not to use \fB-a\fP\fIp\fP option.
120 | .P
121 | When the \fBsrelay\fP is working as the intermediate of socks servers chain, it is some time required to use socks authentication to connect to next-hop socks server. In this case, you can specify the username and password for the next-hop socks by using \fIsrelay.passwd\fP file.
122 | This is done whether you are specifing \fB-a\fP option or not.
123 | .SS srelay.conf
124 | .PP
125 | Configuration file format.
126 | .br
127 | # this line is comment.
128 | .br
129 | # destination port range next [next-p x-next x-next-p]
130 | .br
131 | # subnet length
132 | .br
133 | 123.123.131.0/24 any 10.10.10.1
134 | .br
135 | # subnet mask in doted format higher port is 65535
136 | .br
137 | 223.224.2.128/255.255.255.128 512- 10.11.22.1 11080
138 | .br
139 | # lower port is 1
140 | .br
141 | 223.224.2.128/25 -511 10.11.22.2
142 | .br
143 | # IPv6 destinations go through Gateway
144 | .br
145 | :: - 100.200.1.1
146 | .br
147 | # IPv4 destinations go through another Gateway
148 | .br
149 | 0.0.0.0 - 100.200.1.2
150 | .br
151 | # (IPv6 to IPv4 destinations)
152 | .br
153 | 0.0.0.0 - 3002::1:4321:250:8bff:ffa8:1234
154 | .br
155 | # no next-hop means connect direct.
156 | .br
157 | 1.2.3.4 -
158 | .br
159 | #---
160 |
161 | If a next-p (next-hop socks port) is ommitted, is defaulted to 1080, as you can guess.
162 | A next-hop socks port can be like, 8080/H or 8080/S, where H, S means HTTP, SOCKS, respectively. this also defaults to SOCKS.
163 | .br
164 | HTTP relaying method is experimental, and supports minimized spec of HTTP Proxying.
165 |
166 |
167 | You can be on your network environment like this.
168 | .br
169 | [Client]-->(socks)[srelay]-->(http)[FireWall] -->(socks)[Socks_Island]-->[Dest]
170 |
171 | srelay.conf setting could have the third Host, [FilreWall] like this.
172 |
173 | # dest dest-port proxy proxy-p proxy2 proxy2-p
174 | .br
175 | Dest any Socks-Island 1080 FireWall 8080/H
176 |
177 | The listing order of proxy and proxy2 is farthest first order.
178 |
179 |
180 |
181 |
182 | .br
183 | .SS srelay.passwd
184 | Username/Password information for connecting next-hop socks server.
185 | .br
186 | # this line is comment.
187 | .br
188 | # next-hop server username password
189 | .br
190 | 123.234.0.1 hogehoga xyz$12#
191 | .br
192 | 10.11.22.1 opopop tutut555
193 | .SH FILES
194 | .TP
195 | .B /usr/local/etc/srelay.conf
196 | default configuration file.
197 | .TP
198 | .B /usr/local/etc/srelay.passwd
199 | username/password information using in connecting to the next-hop socks v5 server.
200 | .TP
201 | .B /var/run/srelay.pid
202 | default PID file.
203 | .TP
204 | .B /etc/hosts.allow /etc/hosts.deny
205 | (if supported in compile time,) tcp_wrappers configuration. TAG name is '\fBsrelay\fP'.
206 | .SH SIGNALS
207 | .P
208 | The following signals are meaningful:
209 | .TP
210 | .B SIGHUP
211 | reload srelay.conf.
212 | .TP
213 | .B SIGTERM
214 | Exit.
215 | .SH SEE ALSO
216 | .B hosts_access(5),
217 | .br
218 | .B RFC 1928 SOCKS Protocol Version 5,
219 | .br
220 | .B RFC 1929 Username/Password Authentication for SOCKS V5,
221 | .br
222 | .B http://www.socks.nec.com/socksproto.html
223 | .SH AUTHOR
224 | .B Tomo.M
225 |
226 |
--------------------------------------------------------------------------------
/Frameworks/srelay-0.4.7p3/srelay.conf:
--------------------------------------------------------------------------------
1 | #
2 | # srelay.conf
3 | # $Id: srelay.conf,v 1.5 2009/12/09 04:07:53 bulkstream Exp $
4 | #
5 | # dest[/mask] port proxy proxy-port
6 | ; intranet
7 | 172.16.1.0/24 - 192.168.1.1
8 | 123.123.123.0/255.255.255.248 any 192.168.1.3
9 | 2001:111:1:21::/64 1080 10.1.1.1
10 | :: 21-23 2001::240:2ff:fe3e:b2
11 | c-wind.com - x
12 | 10.1.1.0/25 any 100.100.100.100 1111 firewall 8080/H fw2 1080
13 | 0.0.0.0 any test 1080 test2 firewall/H
14 | #0.0.0.0 -
15 |
--------------------------------------------------------------------------------
/Frameworks/srelay-0.4.7p3/srelay.passwd:
--------------------------------------------------------------------------------
1 | #
2 | # srelay proxy passwd.
3 | # $Id: srelay.passwd,v 1.2 2002/12/06 02:15:01 bulkstream Exp $
4 | #
5 | # proxy user passwd
6 | 192.168.1.1 hogahoge %"aXhe
7 |
--------------------------------------------------------------------------------
/Frameworks/srelay-0.4.7p3/v6defs.h:
--------------------------------------------------------------------------------
1 | /*
2 | v6defs.h:
3 | $Id: v6defs.h,v 1.3 2009/12/09 04:07:53 bulkstream Exp $
4 | IPv6 related definisions mainly for old Solaris.
5 |
6 | Copyright (C) 2003-2009 Tomo.M (author).
7 | All rights reserved.
8 |
9 | Redistribution and use in source and binary forms, with or without
10 | modification, are permitted provided that the following conditions
11 | are met:
12 |
13 | 1. Redistributions of source code must retain the above copyright
14 | notice, this list of conditions and the following disclaimer.
15 | 2. Redistributions in binary form must reproduce the above copyright
16 | notice, this list of conditions and the following disclaimer in the
17 | documentation and/or other materials provided with the distribution.
18 | 3. Neither the name of the author nor the names of its contributors
19 | may be used to endorse or promote products derived from this software
20 | without specific prior written permission.
21 |
22 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
23 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
25 | PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE
26 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
29 | BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
30 | WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
31 | OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
32 | IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 |
34 | */
35 |
36 | #ifndef AF_INET6
37 | #define AF_INET6 24
38 | #endif
39 |
40 | #ifndef PF_INET6
41 | #define PF_INET6 AF_INET6
42 | #endif
43 | struct in6_addr {
44 | u_int8_t s6_addr[16];
45 | };
46 | struct sockaddr_in6 {
47 | #ifdef HAVE_SOCKADDR_SA_LEN
48 | u_int8_t sin6_len; /* length of this struct */
49 | u_int8_t sin6_family; /* AF_INET6 */
50 | #else
51 | u_int16_t sin6_family; /* AF_INET6 */
52 | #endif
53 | u_int16_t sin6_port; /* transport layer port # */
54 | u_int32_t sin6_flowinfo; /* IPv6 flow information */
55 | struct in6_addr sin6_addr; /* IPv6 address */
56 | u_int32_t sin6_scope_id; /* set of interfaces for a scope */
57 | };
58 | #ifndef IN6ADDR_ANY_INIT
59 | #define IN6ADDR_ANY_INIT {{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}}
60 | #endif
61 | #if defined(NEED_SOCKADDR_STORAGE) || !defined(HAS_INET6_STRUCTS)
62 | #define __SS_MAXSIZE 128
63 | #define __SS_ALLIGSIZE (sizeof (long))
64 |
65 | struct sockaddr_storage {
66 | #ifdef HAVE_SOCKADDR_SA_LEN
67 | u_int8_t ss_len; /* address length */
68 | u_int8_t ss_family; /* address family */
69 | char __ss_pad1[__SS_ALLIGSIZE - 2 * sizeof(u_int8_t)];
70 | long __ss_align;
71 | char __ss_pad2[__SS_MAXSIZE - 2 * __SS_ALLIGSIZE];
72 | #else
73 | u_int16_t ss_family; /* address family */
74 | char __ss_pad1[__SS_ALLIGSIZE - sizeof(u_int16_t)];
75 | long __ss_align;
76 | char __ss_pad2[__SS_MAXSIZE - 2 * __SS_ALLIGSIZE];
77 | #endif
78 | };
79 | #endif
80 |
--------------------------------------------------------------------------------
/Frameworks/update.sh:
--------------------------------------------------------------------------------
1 | diff -u polipo-20091115.orig polipo-20091115 > polipo.diff
2 | diff -u srelay-0.4.7p3.orig srelay-0.4.7p3 > srelay.diff
--------------------------------------------------------------------------------
/HISTORY.txt:
--------------------------------------------------------------------------------
1 | Release 2.0.0 (2010-09-26)
2 | - added background support
3 | - added http proxy
4 | - added IP change detection
5 | - added switches to turn on/off proxies
6 | - updated for iOS 4.1
7 | - updated for HD
8 |
9 | Release 1.0.1 (2010-01-19)
10 | - fixed srelay issue
11 |
12 | Release 1.0 (2010-01-19)
13 | - initial relase
--------------------------------------------------------------------------------
/NOTICE.txt:
--------------------------------------------------------------------------------
1 | iProxy itself is originally written by Torsten Curdt and released under the Apache 2.0 License
2 | iProxy is using srelay written by Tomo.M and released under the BSD License
3 |
--------------------------------------------------------------------------------
/README.txt:
--------------------------------------------------------------------------------
1 | At least when you don't want to jailbreak your iPhone so far you've had only one option if you want to connect from your laptop via iPhone to the internet. And that's paying an additional fee to your mobile carrier to provide you with the signed tethering profile.
2 |
3 | iProxy does not give you tethering - it just gives you the next best thing. A http and a socks proxy on your iPhone. Similar to the famous netshare app did before it got pulled from the App Store.
4 |
5 | iProxy is not as convenient as the real tethering. The internet connection is a few clicks more away. But if you've got a developer certificate (or have a friend that has one) it certainly is cheaper than handing out the money to your favorite telco. Especially if you only need this connection every now and then.
6 |
7 | iProxy is just an evening hack of a project so it's far from perfect. But iProxy is released under the Apache license and freely available on github. So fork away if you want to see something fixed.
8 |
9 | This is to give back to the community ...and to stop the ripoff madness.
10 |
11 | Feel free to give some feedback via twitter.
12 |
13 | Torsten
14 | @tcurdt
15 |
16 |
17 | Please check the following links for getting iProxy configured.
18 |
19 | http://github.com/tcurdt/iProxy/wiki
20 | http://github.com/tcurdt/iProxy/wiki/Configuring-iProxy
21 | http://www.memention.com/blog/2010/05/15/Removing-a-step.html
22 |
--------------------------------------------------------------------------------
/Resources/Default.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tcurdt/iProxy/de49da6d99644cc7642934f268814a92818a7380/Resources/Default.png
--------------------------------------------------------------------------------
/Resources/Default@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tcurdt/iProxy/de49da6d99644cc7642934f268814a92818a7380/Resources/Default@2x.png
--------------------------------------------------------------------------------
/Resources/Entitlements.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | application-identifier
5 | $(AppIdentifierPrefix)$(CFBundleIdentifier)
6 | keychain-access-groups
7 |
8 | $(AppIdentifierPrefix)$(CFBundleIdentifier)
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/Resources/Icon-72-transparent.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tcurdt/iProxy/de49da6d99644cc7642934f268814a92818a7380/Resources/Icon-72-transparent.png
--------------------------------------------------------------------------------
/Resources/Icon-72.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tcurdt/iProxy/de49da6d99644cc7642934f268814a92818a7380/Resources/Icon-72.png
--------------------------------------------------------------------------------
/Resources/Icon-Small-50.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tcurdt/iProxy/de49da6d99644cc7642934f268814a92818a7380/Resources/Icon-Small-50.png
--------------------------------------------------------------------------------
/Resources/Icon-Small.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tcurdt/iProxy/de49da6d99644cc7642934f268814a92818a7380/Resources/Icon-Small.png
--------------------------------------------------------------------------------
/Resources/Icon-Small@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tcurdt/iProxy/de49da6d99644cc7642934f268814a92818a7380/Resources/Icon-Small@2x.png
--------------------------------------------------------------------------------
/Resources/Icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tcurdt/iProxy/de49da6d99644cc7642934f268814a92818a7380/Resources/Icon.png
--------------------------------------------------------------------------------
/Resources/Icon@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tcurdt/iProxy/de49da6d99644cc7642934f268814a92818a7380/Resources/Icon@2x.png
--------------------------------------------------------------------------------
/Resources/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | English
7 | CFBundleDisplayName
8 | ${PRODUCT_NAME}
9 | CFBundleExecutable
10 | ${EXECUTABLE_NAME}
11 | CFBundleIconFile
12 | Icon.png
13 | CFBundleIconFiles
14 |
15 | Icon.png
16 | Icon@2x.png
17 | Icon-72.png
18 | Icon-Small-50.png
19 | Icon-Small.png
20 | Icon-Small@2x.png
21 |
22 | CFBundleIdentifier
23 | $(PRODUCT_BUNDLE_IDENTIFIER)
24 | CFBundleInfoDictionaryVersion
25 | 6.0
26 | CFBundleName
27 | ${PRODUCT_NAME}
28 | CFBundlePackageType
29 | APPL
30 | CFBundleSignature
31 | ????
32 | CFBundleVersion
33 | 2.0
34 | LSRequiresIPhoneOS
35 |
36 | NSMainNibFile
37 | MainWindow
38 | UIApplicationExitsOnSuspend
39 |
40 | UIBackgroundModes
41 |
42 | audio
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/Resources/MainWindow.xib:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/Resources/iTunesArtwork:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tcurdt/iProxy/de49da6d99644cc7642934f268814a92818a7380/Resources/iTunesArtwork
--------------------------------------------------------------------------------
/Resources/polipo.config:
--------------------------------------------------------------------------------
1 | # daemonise = true
2 | # scrubLogs = true
3 | # socksProxyType = socks5
4 | # logLevel = 0x07
5 | chunkHighMark = 10000000
6 | objectHighMark = 1024
7 | diskCacheRoot = ""
8 | localDocumentRoot = ""
9 | idleTime = 1
10 | disableLocalInterface = true
11 | disableConfiguration = true
12 | disableIndexing = true
13 | dnsUseGethostbyname = yes
14 |
15 | # allowUnalignedRangeRequests boolean false Allow unaligned range requests (unreliable).
16 | # allowedClients list (not set) Networks from which clients are allowed to connect.
17 | # allowedPorts intlist 80-100, 1024-65535 Ports to which connections are allowed.
18 | # alwaysAddNoTransform boolean false If true, add a no-transform directive to all requests.
19 | # authCredentials atom (hidden) username:password.
20 | # authRealm atom (none) Authentication realm.
21 | # bigBufferSize integer 32768 Size of big buffers (max size of headers).
22 | # cacheIsShared boolean true If false, ignore s-maxage and private.
23 | # censorReferer tristate false Censor referer headers.
24 | # censoredHeaders list (empty list) Headers to censor.
25 | # chunkCriticalMark integer 24772608 Critical mark for chunk memory (0 = auto).
26 | # chunkHighMark integer 25165824 High mark for chunk memory.
27 | # chunkLowMark integer 18874368 Low mark for chunk memory (0 = auto).
28 | # clientTimeout time 2m Client-side timeout.
29 | # disableConfiguration boolean false Disable reconfiguring Polipo at runtime.
30 | # disableIndexing boolean true Disable indexing of the local cache.
31 | # disableLocalInterface boolean false Disable the local configuration pages.
32 | # disableProxy boolean false Whether to be a web server only.
33 | # disableServersList boolean true Disable the list of known servers.
34 | # disableVia boolean true Don't use Via headers.
35 | # diskCacheDirectoryPermissions integer 0700 Access rights for new directories.
36 | # diskCacheFilePermissions integer 0600 Access rights for new cache files.
37 | # diskCacheTruncateSize integer 1048576 Size to which on-disk objects are truncated.
38 | # diskCacheTruncateTime time 4d12h Time after which on-disk objects are truncated.
39 | # diskCacheUnlinkTime time 32d Time after which on-disk objects are removed.
40 | # diskCacheWriteoutOnClose integer 32768 Number of bytes to write out eagerly.
41 | # dnsGethostbynameTtl time 20m TTL for gethostbyname addresses.
42 | # dnsMaxTimeout time 1m Max timeout for DNS queries.
43 | # dnsNameServer atom 127.0.0.1 The name server to use.
44 | # dnsNegativeTtl time 2m TTL for negative DNS replies with no TTL.
45 | # dnsUseGethostbyname 4-state reluctantly Use the system resolver.
46 | # dontCacheCookies boolean false Work around cachable cookies.
47 | # dontCacheRedirects boolean false If true, don't cache redirects.
48 | # dontTrustVaryETag tristate maybe Whether to trust the ETag when there's Vary.
49 | # expectContinue tristate maybe Send Expect-Continue to servers.
50 | # forbiddenFile atom (none) File specifying forbidden URLs.
51 | # forbiddenRedirectCode integer 302 Redirect code, 301 or 302.
52 | # forbiddenUrl atom (none) URL to which forbidden requests should be redirected.
53 | # idleTime time 20s Time to remain idle before writing out.
54 | # laxHttpParser boolean true Ignore unknown HTTP headers.
55 | # logFacility atom user Syslog facility to use.
56 | # logFile atom (none) Log file (stderr if empty and logSyslog is unset, /var/log/polipo if empty and daemonise is true).
57 | # logFilePermissions integer 0640 Access rights of the logFile.
58 | # logSyslog boolean false Log to syslog.
59 | # maxAge time 14d1h Max age for objects without Expires header.
60 | # maxAgeFraction float 0.100000 Fresh fraction of modification time.
61 | # maxConnectionAge time 21m Maximum age of a server-side connection.
62 | # maxConnectionRequests integer 400 Maximum number of requests on a server-side connection.
63 | # maxDiskCacheEntrySize integer -1 Maximum size of objects cached on disk.
64 | # maxDiskEntries integer 32 File descriptors used by the on-disk cache.
65 | # maxExpiresAge time 30d1h Max age for objects with Expires header.
66 | # maxNoModifiedAge time 23m Max age for objects without Last-modified.
67 | # maxObjectsWhenIdle integer 32 Number of objects to write at a time when idle.
68 | # maxPipelineTrain integer 10 Maximum number of requests pipelined at a time.
69 | # maxSideBuffering integer 1500 Maximum buffering for PUT and POST requests.
70 | # maxWriteoutWhenIdle integer 65536 Amount of data to write at a time when idle.
71 | # mindlesslyCacheVary boolean false If true, mindlessly cache negotiated objects.
72 | # objectHashTableSize integer 32768 Size of the object hash table (0 = auto).
73 | # objectHighMark integer 2048 High object count mark.
74 | # parentAuthCredentials atom (hidden) username:password.
75 | # parentProxy atom (none) Parent proxy (host:port).
76 | # pidFile atom (none) File with pid of running daemon.
77 | # pipelineAdditionalRequests tristate maybe Pipeline requests on an active connection.
78 | # pmmFirstSize integer 0 The size of the first PMM chunk.
79 | # pmmSize integer 0 The size of a PMM chunk.
80 | # preciseExpiry boolean false Whether to consider all files for purging.
81 | # proxyAddress atom 127.0.0.1 The IP address on which the proxy listens.
82 | # proxyName atom shodan.local The name by which the proxy is known.
83 | # proxyOffline boolean false Avoid contacting remote servers.
84 | # proxyPort integer 8123 The TCP port on which the proxy listens.
85 | # publicObjectLowMark integer 1024 Low object count mark (0 = auto).
86 | # redirector atom (none) Squid-style redirector.
87 | # redirectorRedirectCode integer 302 Redirect code to use with redirector.
88 | # relaxTransparency tristate false Avoid contacting remote servers.
89 | # replyUnpipelineSize integer 1048576 Size for a pipeline break.
90 | # replyUnpipelineTime time 20s Estimated time for a pipeline break.
91 | # serverExpireTime time 1d Time during which server data is valid.
92 | # serverIdleTimeout time 45s Server-side idle timeout.
93 | # serverMaxSlots integer 8 Maximum number of connections per broken server.
94 | # serverSlots integer 2 Maximum number of connections per server.
95 | # serverSlots1 integer 4 Maximum number of connections per HTTP/1.0 server.
96 | # serverTimeout time 1m30s Server-side timeout.
97 | # smallRequestTime time 10s Estimated time for a small request.
98 | # socksParentProxy atom (none) SOCKS parent proxy (host:port)
99 | # socksUserName atom (empty) SOCKS4a user name
100 | # tunnelAllowedPorts intlist 22, 80, 109-110, 143, 443, 873, 993, 995, 2401, 5222-5223, 9418 Ports to which tunnelled connections are allowed.
101 | # uncachableFile atom (none) File specifying uncachable URLs.
--------------------------------------------------------------------------------
/Resources/silence.wav:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tcurdt/iProxy/de49da6d99644cc7642934f268814a92818a7380/Resources/silence.wav
--------------------------------------------------------------------------------
/Sources/AppDelegate.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2010, Torsten Curdt
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | @class MainViewController;
18 |
19 | @interface AppDelegate : NSObject {
20 |
21 | IBOutlet UIWindow *window;
22 | IBOutlet MainViewController *statusViewController;
23 | }
24 |
25 | @property (nonatomic, retain) UIWindow *window;
26 | @property (nonatomic, retain) MainViewController *statusViewController;
27 |
28 | @end
--------------------------------------------------------------------------------
/Sources/AppDelegate.m:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2010, Torsten Curdt
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | #import "AppDelegate.h"
18 | #import "MainViewController.h"
19 |
20 | @interface UIApplication (PrivateAPI)
21 | - (void)_terminateWithStatus:(int)status;
22 | @end
23 |
24 |
25 | @implementation AppDelegate
26 |
27 | @synthesize window;
28 | @synthesize statusViewController;
29 |
30 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
31 | {
32 | [window setRootViewController:statusViewController];
33 | [window makeKeyAndVisible];
34 |
35 | application.idleTimerDisabled = YES;
36 |
37 | // setup fake audio
38 |
39 | NSError *error = nil;
40 |
41 | AVAudioSession *session = [AVAudioSession sharedInstance];
42 | session.delegate = self;
43 |
44 | if (![session setCategory:AVAudioSessionCategoryPlayback error:&error]) {
45 | NSLog(@"ERROR: audio category %@", error);
46 | }
47 |
48 | if (![session setActive:YES error:&error]) {
49 | NSLog(@"ERROR: audio active %@", error);
50 | }
51 |
52 | NSString *sample = [[NSBundle mainBundle] pathForResource:@"silence" ofType:@"wav"];
53 | NSURL *url = [NSURL URLWithString:sample];
54 | AVAudioPlayer *player = [[AVAudioPlayer alloc] initWithContentsOfURL:url error:&error];
55 | player.numberOfLoops = -1;
56 | player.volume = 0.00;
57 | [player prepareToPlay];
58 | [player play];
59 |
60 | return YES;
61 | }
62 |
63 |
64 | - (void)beginInterruption
65 | {
66 | NSLog(@"audio interruption started");
67 | }
68 |
69 | - (void)endInterruption
70 | {
71 | NSLog(@"audio interruption ended");
72 |
73 | AVAudioSession *session = [AVAudioSession sharedInstance];
74 |
75 | NSError *error = nil;
76 |
77 | if (![session setActive:YES error:&error]) {
78 | NSLog(@"ERROR: audio active %@", error);
79 | }
80 |
81 | // resume playback
82 | }
83 |
84 | - (void)applicationWillResignActive:(UIApplication *)application
85 | {
86 | }
87 |
88 | - (void)applicationDidBecomeActive:(UIApplication *)application
89 | {
90 | }
91 |
92 | - (void)applicationWillEnterForeground:(UIApplication *)application
93 | {
94 | }
95 |
96 | - (void)applicationDidEnterBackground:(UIApplication *)application
97 | {
98 | if (!statusViewController.proxyHttpRunning && !statusViewController.proxySocksRunning) {
99 | [[UIApplication sharedApplication] _terminateWithStatus:0];
100 | }
101 | }
102 |
103 | - (void)applicationWillTerminate:(UIApplication *)application
104 | {
105 | }
106 |
107 | - (void)dealloc
108 | {
109 | [statusViewController release];
110 | [window release];
111 | [super dealloc];
112 | }
113 |
114 | @end
115 |
--------------------------------------------------------------------------------
/Sources/HTTPResponseHandler.h:
--------------------------------------------------------------------------------
1 | //
2 | // HTTPResponseHandler.h
3 | // TextTransfer
4 | //
5 | // Created by Matt Gallagher on 2009/07/13.
6 | // Copyright 2009 Matt Gallagher. All rights reserved.
7 | //
8 | // Permission is given to use this source code file, free of charge, in any
9 | // project, commercial or otherwise, entirely at your risk, with the condition
10 | // that any redistribution (in part or whole) of source code must retain
11 | // this copyright and permission notice. Attribution in compiled projects is
12 | // appreciated but not required.
13 | //
14 |
15 | #if TARGET_OS_IPHONE
16 | #import
17 | #import
18 | #else
19 | #import
20 | #endif
21 |
22 | @class HTTPServer;
23 |
24 | @interface HTTPResponseHandler : NSObject
25 | {
26 | CFHTTPMessageRef request;
27 | NSString *requestMethod;
28 | NSDictionary *headerFields;
29 | NSFileHandle *fileHandle;
30 | HTTPServer *server;
31 | NSURL *url;
32 | }
33 |
34 | + (NSUInteger)priority;
35 | + (void)registerHandler:(Class)handlerClass;
36 |
37 | + (HTTPResponseHandler *)handlerForRequest:(CFHTTPMessageRef)aRequest
38 | fileHandle:(NSFileHandle *)requestFileHandle
39 | server:(HTTPServer *)aServer;
40 |
41 | - (id)initWithRequest:(CFHTTPMessageRef)aRequest
42 | method:(NSString *)method
43 | url:(NSURL *)requestURL
44 | headerFields:(NSDictionary *)requestHeaderFields
45 | fileHandle:(NSFileHandle *)requestFileHandle
46 | server:(HTTPServer *)aServer;
47 | - (void)startResponse;
48 | - (NSString *)serverIPForRequest;
49 | - (void)endResponse;
50 |
51 | @end
52 |
--------------------------------------------------------------------------------
/Sources/HTTPServer.h:
--------------------------------------------------------------------------------
1 | //
2 | // HTTPServer.h
3 | // TextTransfer
4 | //
5 | // Created by Matt Gallagher on 2009/07/13.
6 | // Copyright 2009 Matt Gallagher. All rights reserved.
7 | //
8 | // Permission is given to use this source code file, free of charge, in any
9 | // project, commercial or otherwise, entirely at your risk, with the condition
10 | // that any redistribution (in part or whole) of source code must retain
11 | // this copyright and permission notice. Attribution in compiled projects is
12 | // appreciated but not required.
13 | //
14 |
15 | #if TARGET_OS_IPHONE
16 | #import
17 | #else
18 | #import
19 | #endif
20 |
21 | typedef enum
22 | {
23 | SERVER_STATE_IDLE,
24 | SERVER_STATE_STARTING,
25 | SERVER_STATE_RUNNING,
26 | SERVER_STATE_STOPPING
27 | } HTTPServerState;
28 |
29 | @class HTTPResponseHandler;
30 |
31 | @interface HTTPServer : NSObject
32 | {
33 | NSError *lastError;
34 | NSFileHandle *listeningHandle;
35 | CFSocketRef socket;
36 | HTTPServerState state;
37 | CFMutableDictionaryRef incomingRequests;
38 | NSMutableSet *responseHandlers;
39 | NSNetService *netService;
40 | }
41 |
42 | @property (nonatomic, readonly, retain) NSError *lastError;
43 | @property (readonly, assign) HTTPServerState state;
44 | @property (readonly) UInt32 httpServerPort;
45 |
46 | + (HTTPServer *)sharedHTTPServer;
47 |
48 | - (void)start;
49 | - (void)stop;
50 |
51 | - (void)closeHandler:(HTTPResponseHandler *)aHandler;
52 |
53 | @end
54 |
55 | extern NSString * const HTTPServerNotificationStateChanged;
56 |
--------------------------------------------------------------------------------
/Sources/InfoViewController.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2010, Torsten Curdt
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | @interface InfoViewController : UIViewController {
18 |
19 | }
20 |
21 | - (IBAction) actionLike;
22 | - (IBAction) actionHelp;
23 | - (IBAction) actionIssues;
24 | - (IBAction) actionDonate;
25 |
26 | @end
27 |
--------------------------------------------------------------------------------
/Sources/InfoViewController.m:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2010, Torsten Curdt
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | #import "InfoViewController.h"
18 |
19 | @implementation InfoViewController
20 |
21 | - (void) viewDidLoad
22 | {
23 | CAGradientLayer *gradient = [CAGradientLayer layer];
24 | gradient.frame = self.view.bounds;
25 | gradient.colors = [NSArray arrayWithObjects:
26 | (id)[RGB(241,231,165) CGColor],
27 | (id)[RGB(208,180,35) CGColor],
28 | nil];
29 | [self.view.layer insertSublayer:gradient atIndex:0];
30 |
31 | self.title = @"Info";
32 | self.navigationItem.rightBarButtonItem = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(dismiss)] autorelease];
33 | }
34 |
35 | - (IBAction) actionLike;
36 | {
37 | NSString *anonymizedUnique = [[[UIDevice currentDevice] uniqueIdentifier] md5];
38 |
39 | #if TARGET_IPHONE_SIMULATOR
40 | NSURL *url = [NSURL URLWithString: [NSString stringWithFormat: @"http://localhost?%@", anonymizedUnique]];
41 | #else
42 | NSURL *url = [NSURL URLWithString: [NSString stringWithFormat: URL_LIKE, anonymizedUnique]];
43 | #endif
44 |
45 | NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:url];
46 | [[NSURLConnection alloc] initWithRequest:request delegate:self startImmediately:YES];
47 | }
48 |
49 | - (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response
50 | {
51 | if ([(NSHTTPURLResponse*)response statusCode] == 200) {
52 |
53 | [connection release];
54 |
55 | UIAlertView *view = [[UIAlertView alloc] initWithTitle: @"Like It!"
56 | message: @"Thanks for the feedback!"
57 | delegate: self cancelButtonTitle: @"OK" otherButtonTitles: nil];
58 |
59 | [view show];
60 | [view release];
61 |
62 | return;
63 | }
64 |
65 | [self connection:connection didFailWithError:nil];
66 | }
67 |
68 | - (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error
69 | {
70 | [connection release];
71 |
72 | UIAlertView *view = [[UIAlertView alloc] initWithTitle: @"Like It!"
73 | message: @"That somehow did not get through. But thanks for trying!"
74 | delegate: self cancelButtonTitle: @"OK" otherButtonTitles: nil];
75 |
76 | [view show];
77 | [view release];
78 | }
79 |
80 |
81 | - (IBAction) actionHelp
82 | {
83 | [[UIApplication sharedApplication] openURL:[NSURL URLWithString: URL_HELP]];
84 | }
85 |
86 | - (IBAction) actionIssues
87 | {
88 | [[UIApplication sharedApplication] openURL:[NSURL URLWithString: URL_ISSUES]];
89 | }
90 |
91 | - (IBAction) actionDonate
92 | {
93 | [[UIApplication sharedApplication] openURL:[NSURL URLWithString: URL_DONATE]];
94 | }
95 |
96 | - (void) dismiss
97 | {
98 | [self dismissModalViewControllerAnimated:YES];
99 | }
100 |
101 | @end
102 |
--------------------------------------------------------------------------------
/Sources/MainViewController.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2010, Torsten Curdt
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | #import
17 |
18 | @interface MainViewController : UIViewController {
19 |
20 | IBOutlet UISwitch *httpSwitch;
21 | IBOutlet UILabel *httpAddressLabel;
22 | IBOutlet UILabel *httpPacLabel;
23 | IBOutlet UIButton *httpPacButton;
24 |
25 | IBOutlet UISwitch *socksSwitch;
26 | IBOutlet UILabel *socksAddressLabel;
27 | IBOutlet UILabel *socksPacLabel;
28 | IBOutlet UIButton *socksPacButton;
29 |
30 | IBOutlet UIView *connectView;
31 | IBOutlet UIView *runningView;
32 |
33 | BOOL proxyHttpRunning;
34 | BOOL proxySocksRunning;
35 | BOOL httpRunning;
36 |
37 | NSString *emailBody;
38 | NSString *emailURL;
39 |
40 | NSString *ip;
41 |
42 | NSNetService *socksProxyNetService;
43 | NSNetService *httpProxyNetService;
44 | }
45 |
46 | - (void) proxyHttpStart;
47 | - (void) proxyHttpStop;
48 |
49 | - (void) proxySocksStart;
50 | - (void) proxySocksStop;
51 |
52 | - (void) httpStart;
53 | - (void) httpStop;
54 |
55 | - (IBAction) switchedHttp:(id)sender;
56 | - (IBAction) switchedSocks:(id)sender;
57 | - (IBAction) httpURLAction:(id)sender;
58 | - (IBAction) socksURLAction:(id)sender;
59 | - (IBAction) showInfo;
60 |
61 | @property (nonatomic, retain) UISwitch *httpSwitch;
62 | @property (nonatomic, retain) UILabel *httpAddressLabel;
63 | @property (nonatomic, retain) UILabel *httpPacLabel;
64 | @property (nonatomic, retain) UISwitch *socksSwitch;
65 | @property (nonatomic, retain) UILabel *socksAddressLabel;
66 | @property (nonatomic, retain) UILabel *socksPacLabel;
67 | @property (nonatomic, retain) UIView *connectView;
68 | @property (nonatomic, retain) UIView *runningView;
69 | @property (assign) BOOL proxyHttpRunning;
70 | @property (assign) BOOL proxySocksRunning;
71 | @property (assign) BOOL httpRunning;
72 | @property (nonatomic, retain) NSString *ip;
73 |
74 | @end
75 |
76 |
--------------------------------------------------------------------------------
/Sources/NSStringAdditions.h:
--------------------------------------------------------------------------------
1 | @interface NSString (NSStringAdditions)
2 |
3 | - (NSString*) URLEncodedString;
4 | - (NSString*) URLDecodedString;
5 | - (NSString*) md5;
6 |
7 | @end
8 |
--------------------------------------------------------------------------------
/Sources/NSStringAdditions.m:
--------------------------------------------------------------------------------
1 | #import "NSStringAdditions.h"
2 | #import
3 |
4 | @implementation NSString (NSStringAdditions)
5 |
6 | - (NSString*) URLEncodedString
7 | {
8 | NSString *result = (NSString *)CFURLCreateStringByAddingPercentEscapes(
9 | kCFAllocatorDefault,
10 | (CFStringRef)self,
11 | NULL,
12 | CFSTR("!*'();:@&=+$,/?%#[]"),
13 | kCFStringEncodingUTF8);
14 |
15 | return [result autorelease];
16 | }
17 |
18 | - (NSString*) URLDecodedString
19 | {
20 | NSString *result = (NSString *)CFURLCreateStringByReplacingPercentEscapesUsingEncoding(
21 | kCFAllocatorDefault,
22 | (CFStringRef)self,
23 | CFSTR(""),
24 | kCFStringEncodingUTF8);
25 |
26 | return [result autorelease];
27 | }
28 |
29 | - (NSString *) md5
30 | {
31 | const char *cStr = [self UTF8String];
32 | unsigned char result[16];
33 | CC_MD5( cStr, strlen(cStr), result );
34 | return [NSString stringWithFormat:
35 | @"%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X",
36 | result[0], result[1], result[2], result[3],
37 | result[4], result[5], result[6], result[7],
38 | result[8], result[9], result[10], result[11],
39 | result[12], result[13], result[14], result[15]
40 | ];
41 | }
42 |
43 | @end
44 |
--------------------------------------------------------------------------------
/Sources/PacFileResponse.h:
--------------------------------------------------------------------------------
1 | //
2 | // AppTextFileResponse.h
3 | // TextTransfer
4 | //
5 | // Created by Matt Gallagher on 2009/07/13.
6 | // Copyright 2009 Matt Gallagher. All rights reserved.
7 | //
8 | // Permission is given to use this source code file, free of charge, in any
9 | // project, commercial or otherwise, entirely at your risk, with the condition
10 | // that any redistribution (in part or whole) of source code must retain
11 | // this copyright and permission notice. Attribution in compiled projects is
12 | // appreciated but not required.
13 | //
14 |
15 | #import "HTTPResponseHandler.h"
16 |
17 | @interface PacFileResponse : HTTPResponseHandler
18 | {
19 |
20 | }
21 |
22 | @end
23 |
--------------------------------------------------------------------------------
/Sources/PacFileResponse.m:
--------------------------------------------------------------------------------
1 | //
2 | // AppTextFileResponse.m
3 | // TextTransfer
4 | //
5 | // Created by Matt Gallagher on 2009/07/13.
6 | // Copyright 2009 Matt Gallagher. All rights reserved.
7 | //
8 | // Permission is given to use this source code file, free of charge, in any
9 | // project, commercial or otherwise, entirely at your risk, with the condition
10 | // that any redistribution (in part or whole) of source code must retain
11 | // this copyright and permission notice. Attribution in compiled projects is
12 | // appreciated but not required.
13 | //
14 |
15 | #import "PacFileResponse.h"
16 | #import "HTTPServer.h"
17 |
18 | @implementation PacFileResponse
19 |
20 | //
21 | // load
22 | //
23 | // Implementing the load method and invoking
24 | // [HTTPResponseHandler registerHandler:self] causes HTTPResponseHandler
25 | // to register this class in the list of registered HTTP response handlers.
26 | //
27 | + (void)load
28 | {
29 | [HTTPResponseHandler registerHandler:self];
30 | }
31 |
32 | //
33 | // canHandleRequest:method:url:headerFields:
34 | //
35 | // Class method to determine if the response handler class can handle
36 | // a given request.
37 | //
38 | // Parameters:
39 | // aRequest - the request
40 | // requestMethod - the request method
41 | // requestURL - the request URL
42 | // requestHeaderFields - the request headers
43 | //
44 | // returns YES (if the handler can handle the request), NO (otherwise)
45 | //
46 | + (BOOL)canHandleRequest:(CFHTTPMessageRef)aRequest
47 | method:(NSString *)requestMethod
48 | url:(NSURL *)requestURL
49 | headerFields:(NSDictionary *)requestHeaderFields
50 | {
51 | return YES;
52 | }
53 |
54 | //
55 | // startResponse
56 | //
57 | // Since this is a simple response, we handle it synchronously by sending
58 | // everything at once.
59 | //
60 | - (void)startResponse
61 | {
62 | NSData *fileData = nil;
63 | NSString *currentIP = [self serverIPForRequest];
64 |
65 | NSString *requestPath = [url path];
66 |
67 | if ([@"/http.pac" isEqualToString:requestPath] && currentIP) {
68 | fileData = [[NSString stringWithFormat:
69 | @"function FindProxyForURL(url, host) { return \"PROXY %@:%d\"; }",
70 | currentIP, HTTP_PROXY_PORT] dataUsingEncoding:NSUTF8StringEncoding];
71 | }
72 |
73 | if ([@"/socks.pac" isEqualToString:requestPath] && currentIP) {
74 | fileData = [[NSString stringWithFormat:
75 | @"function FindProxyForURL(url, host) { return \"SOCKS %@:%d\"; }",
76 | currentIP, SOCKS_PROXY_PORT] dataUsingEncoding:NSUTF8StringEncoding];
77 | }
78 |
79 | if (fileData) {
80 | CFHTTPMessageRef response = CFHTTPMessageCreateResponse(kCFAllocatorDefault,
81 | 200,
82 | NULL,
83 | kCFHTTPVersion1_1);
84 |
85 | CFHTTPMessageSetHeaderFieldValue(response,
86 | (CFStringRef)@"Content-Type",
87 | (CFStringRef)@"application/x-ns-proxy-autoconfig");
88 | CFHTTPMessageSetHeaderFieldValue(response,
89 | (CFStringRef)@"Connection",
90 | (CFStringRef)@"close");
91 | CFHTTPMessageSetHeaderFieldValue(response,
92 | (CFStringRef)@"Content-Length",
93 | (CFStringRef)[NSString stringWithFormat:@"%ld", [fileData length]]);
94 |
95 | CFDataRef headerData = CFHTTPMessageCopySerializedMessage(response);
96 |
97 | @try
98 | {
99 | [fileHandle writeData:(NSData *)headerData];
100 | [fileHandle writeData:fileData];
101 | }
102 | @catch (NSException *exception)
103 | {
104 | // Ignore the exception, it normally just means the client
105 | // closed the connection from the other end.
106 | }
107 | @finally
108 | {
109 | CFRelease(headerData);
110 | [server closeHandler:self];
111 | }
112 | } else {
113 | CFHTTPMessageRef response = CFHTTPMessageCreateResponse(kCFAllocatorDefault,
114 | currentIP ? 404 : 500,
115 | NULL,
116 | kCFHTTPVersion1_1);
117 |
118 | CFDataRef headerData = CFHTTPMessageCopySerializedMessage(response);
119 |
120 | @try
121 | {
122 | [fileHandle writeData:(NSData *)headerData];
123 | }
124 | @catch (NSException *exception)
125 | {
126 | // Ignore the exception, it normally just means the client
127 | // closed the connection from the other end.
128 | }
129 | @finally
130 | {
131 | CFRelease(headerData);
132 | [server closeHandler:self];
133 | }
134 | }
135 | }
136 |
137 | @end
138 |
--------------------------------------------------------------------------------
/Sources/Prefix.pch:
--------------------------------------------------------------------------------
1 | #ifdef __OBJC__
2 | #import
3 | #import
4 |
5 | #import
6 | #import
7 |
8 | #import "UIDeviceAdditions.h"
9 | #import "UIViewAdditions.h"
10 | #import "NSStringAdditions.h"
11 | #endif
12 |
13 | // polipo
14 | #define HAS_STDINT_H
15 |
16 | // srelay
17 | #define HAVE_SOCKADDR_DL_STRUCT
18 | #define MACOSX
19 | #define HAVE_UINT32_T
20 | #define HAVE_SOCKLEN_T
21 | // #define USE_THREAD 1
22 |
23 | // color macros
24 | #define RGB(r,g,b) [UIColor colorWithRed:(float)r/0xff green:(float)g/0xff blue:(float)b/0xff alpha:1.0]
25 | #define RGBA(r,g,b,a) [UIColor colorWithRed:(float)r/0xff green:(float)g/0xff blue:(float)b/0xff alpha:a]
26 |
27 | // defaults keys
28 | #define KEY_SOCKS_ON @"socks.on"
29 | #define KEY_HTTP_ON @"http.on"
30 |
31 | // ports
32 | #define HTTP_PROXY_PORT 8888
33 | #define SOCKS_PROXY_PORT 1080
34 | #define HTTP_SERVER_PORT 8000
35 |
36 | // urls
37 | #define URL_HELP @"http://github.com/tcurdt/iProxy/wiki/Configuring-iProxy"
38 | #define URL_ISSUES @"http://github.com/tcurdt/iProxy/issues"
39 | #define URL_LIKE @"http://vafer.org/log/iproxy?%@"
40 | #define URL_DONATE @"https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=tcurdt%40vafer.org&item_name=Thanks%20for%20iProxy¤cy_code=EUR&lc=US"
41 |
--------------------------------------------------------------------------------
/Sources/StatusViewController.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2010, Torsten Curdt
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | #import
18 | #import
19 |
20 | @interface StatusViewController : UIViewController {
21 |
22 | IBOutlet UILabel *ipLabel;
23 | IBOutlet UILabel *portLabel;
24 | IBOutlet UILabel *pacLabel;
25 | IBOutlet UILabel *uploadLabel;
26 | IBOutlet UILabel *downloadLabel;
27 |
28 | }
29 |
30 | @property (nonatomic, retain) UILabel *ipLabel;
31 | @property (nonatomic, retain) UILabel *portLabel;
32 | @property (nonatomic, retain) UILabel *pacLabel;
33 | @property (nonatomic, retain) UILabel *uploadLabel;
34 | @property (nonatomic, retain) UILabel *downloadLabel;
35 |
36 | -(IBAction)showInstructions;
37 | -(IBAction)pacURLAction:(id)sender;
38 |
39 | @end
40 |
41 |
--------------------------------------------------------------------------------
/Sources/SynthesizeSingleton.h:
--------------------------------------------------------------------------------
1 | //
2 | // SynthesizeSingleton.h
3 | // iTrackSportsBets
4 | //
5 | // Created by Matt Gallagher on 20/10/08.
6 | // Copyright 2008 Matt Gallagher. All rights reserved.
7 | //
8 | // Permission is given to use this source code file, free of charge, in any
9 | // project, commercial or otherwise, entirely at your risk, with the condition
10 | // that any redistribution (in part or whole) of source code must retain
11 | // this copyright and permission notice. Attribution in compiled projects is
12 | // appreciated but not required.
13 | //
14 |
15 | #define SYNTHESIZE_SINGLETON_FOR_CLASS(classname) \
16 | \
17 | static classname *shared##classname = nil; \
18 | \
19 | + (classname *)shared##classname \
20 | { \
21 | @synchronized(self) \
22 | { \
23 | if (shared##classname == nil) \
24 | { \
25 | shared##classname = [[self alloc] init]; \
26 | } \
27 | } \
28 | \
29 | return shared##classname; \
30 | } \
31 | \
32 | + (id)allocWithZone:(NSZone *)zone \
33 | { \
34 | @synchronized(self) \
35 | { \
36 | if (shared##classname == nil) \
37 | { \
38 | shared##classname = [super allocWithZone:zone]; \
39 | return shared##classname; \
40 | } \
41 | } \
42 | \
43 | return nil; \
44 | } \
45 | \
46 | - (id)copyWithZone:(NSZone *)zone \
47 | { \
48 | return self; \
49 | } \
50 | \
51 | - (id)retain \
52 | { \
53 | return self; \
54 | } \
55 | \
56 | - (NSUInteger)retainCount \
57 | { \
58 | return NSUIntegerMax; \
59 | } \
60 | \
61 | - (void)release \
62 | { \
63 | } \
64 | \
65 | - (id)autorelease \
66 | { \
67 | return self; \
68 | }
69 |
--------------------------------------------------------------------------------
/Sources/UIDeviceAdditions.h:
--------------------------------------------------------------------------------
1 | @interface UIDevice (UIDeviceAdditions)
2 |
3 | - (NSString *)IPAddressForInterface:(NSString*)ifname;
4 |
5 | @end
6 |
--------------------------------------------------------------------------------
/Sources/UIDeviceAdditions.m:
--------------------------------------------------------------------------------
1 | #import "UIDeviceAdditions.h"
2 |
3 | #import
4 | #import
5 |
6 | @implementation UIDevice (UIDeviceAdditions)
7 |
8 | - (NSString *)IPAddressForInterface:(NSString*)ifname
9 | {
10 | NSString *address = nil;
11 |
12 | struct ifaddrs *interfaces = NULL;
13 |
14 | int success = getifaddrs(&interfaces);
15 |
16 | if (success == 0) {
17 | struct ifaddrs *temp_addr = NULL;
18 |
19 | temp_addr = interfaces;
20 | while(temp_addr != NULL) {
21 |
22 | if(temp_addr->ifa_addr->sa_family == AF_INET) {
23 |
24 | if([[NSString stringWithUTF8String:temp_addr->ifa_name] isEqualToString:ifname]) {
25 |
26 | address = [NSString stringWithUTF8String:inet_ntoa(((struct sockaddr_in *)temp_addr->ifa_addr)->sin_addr)];
27 | }
28 | }
29 |
30 | temp_addr = temp_addr->ifa_next;
31 | }
32 | }
33 |
34 | freeifaddrs(interfaces);
35 |
36 | return address;
37 | }
38 |
39 | @end
40 |
--------------------------------------------------------------------------------
/Sources/UIViewAdditions.h:
--------------------------------------------------------------------------------
1 | @interface UIView (UIViewAdditions)
2 |
3 | - (UIView*) addTaggedSubview:(UIView*)theView;
4 |
5 | @end
6 |
--------------------------------------------------------------------------------
/Sources/UIViewAdditions.m:
--------------------------------------------------------------------------------
1 | #import "UIViewAdditions.h"
2 |
3 | @implementation UIView (UIViewAdditions)
4 |
5 | - (UIView*) addTaggedSubview:(UIView*)theView
6 | {
7 | for(UIView *view in [self subviews]) {
8 |
9 | if (view.tag == theView.tag && view != theView) {
10 | UIView *removedView = view;
11 | [self insertSubview:theView aboveSubview:view];
12 | [view removeFromSuperview];
13 | // NSLog(@"replaced %@ with %@", removedView, theView);
14 | return removedView;
15 | }
16 | }
17 |
18 | [self addSubview:theView];
19 | return nil;
20 | }
21 |
22 | @end
23 |
--------------------------------------------------------------------------------
/Sources/main.m:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2010, Torsten Curdt
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | #import
18 |
19 | int main(int argc, char *argv[]) {
20 |
21 | NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
22 | int retVal = UIApplicationMain(argc, argv, nil, nil);
23 | [pool release];
24 | return retVal;
25 | }
26 |
--------------------------------------------------------------------------------
/iProxy.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDEDidComputeMac32BitWarning
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/iProxy.xcodeproj/xcshareddata/xcschemes/iProxy.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
24 |
25 |
30 |
31 |
32 |
33 |
43 |
45 |
51 |
52 |
53 |
54 |
60 |
62 |
68 |
69 |
70 |
71 |
73 |
74 |
77 |
78 |
79 |
--------------------------------------------------------------------------------