diff -ur stunnel-4.33/src/client.c stunnel-4.33.sendproxy/src/client.c
--- stunnel-4.33/src/client.c 2010-04-04 23:00:29.000000000 +0200
+++ stunnel-4.33.sendproxy/src/client.c 2010-10-15 17:33:13.625135151 +0200
@@ -88,6 +88,8 @@
c->opt=opt;
c->local_rfd.fd=rfd;
c->local_wfd.fd=wfd;
+ if (c->opt->option.sendproxy)
+ c->sendproxy = 1;
return c;
}
@@ -591,7 +593,73 @@
watchdog=0; /* reset watchdog */
}
}
-
+ if (c->sendproxy && !c->ssl_ptr) {
+ int cfd;
+ struct sockaddr_storage local_addr;
+ struct sockaddr_storage peer_addr;
+ u_char family = AF_UNSPEC;
+
+ cfd = SSL_get_fd(c->ssl);
+ if (cfd != -1) {
+ size_t namelen;
+
+ namelen = sizeof(local_addr);
+ if (!getsockname(cfd, (struct sockaddr *)&local_addr, &namelen)) {
+ namelen = sizeof(peer_addr);
+ if (!getpeername(cfd, (struct sockaddr *)&peer_addr, &namelen))
+ family = peer_addr.ss_family;
+ }
+ }
+
+ if (family == AF_INET) {
+
+ if (BUFFSIZE >= 11) {
+ memcpy(c->ssl_buff, "PROXY TCP4 ", 11);
+ c->ssl_ptr += 11;
+ }
+
+ if (inet_ntop(peer_addr.ss_family, &((struct sockaddr_in*)&peer_addr)->sin_addr, c->ssl_buff+c->ssl_ptr, BUFFSIZE-c->ssl_ptr)) {
+ c->ssl_ptr += strlen(c->ssl_buff+c->ssl_ptr);
+ }
+ if (c->ssl_ptr != BUFFSIZE) {
+ c->ssl_buff[c->ssl_ptr] = ' ';
+ c->ssl_ptr++;
+ }
+ if (inet_ntop(local_addr.ss_family, &((struct sockaddr_in*)&local_addr)->sin_addr, c->ssl_buff+c->ssl_ptr, BUFFSIZE-c->ssl_ptr)) {
+ c->ssl_ptr += strlen(c->ssl_buff+c->ssl_ptr);
+ }
+ c->ssl_ptr += snprintf(c->ssl_buff+c->ssl_ptr, BUFFSIZE-c->ssl_ptr, " %u %u\r\n", ntohs(((struct sockaddr_in*)&peer_addr)->sin_port), ntohs(((struct sockaddr_in*)&local_addr)->sin_port));
+ }
+#if defined(USE_IPv6) && !defined(USE_WIN32)
+ else if (family == AF_INET6) {
+
+ if (BUFFSIZE >= 11) {
+ memcpy(c->ssl_buff, "PROXY TCP6 ", 11);
+ c->ssl_ptr += 11;
+ }
+
+ if (inet_ntop(peer_addr.ss_family, &((struct sockaddr_in6*)&peer_addr)->sin6_addr, c->ssl_buff+c->ssl_ptr, BUFFSIZE-c->ssl_ptr)) {
+ c->ssl_ptr += strlen(c->ssl_buff+c->ssl_ptr);
+ }
+ if (c->ssl_ptr != BUFFSIZE) {
+ c->ssl_buff[c->ssl_ptr] = ' ';
+ c->ssl_ptr++;
+ }
+ if (inet_ntop(local_addr.ss_family, &((struct sockaddr_in6*)&local_addr)->sin6_addr, c->ssl_buff+c->ssl_ptr, BUFFSIZE-c->ssl_ptr)) {
+ c->ssl_ptr += strlen(c->ssl_buff+c->ssl_ptr);
+ }
+ c->ssl_ptr += snprintf(c->ssl_buff+c->ssl_ptr, BUFFSIZE-c->ssl_ptr, " %u %u\r\n", ntohs(((struct sockaddr_in6*)&peer_addr)->sin6_port), ntohs(((struct sockaddr_in6*)&local_addr)->sin6_port));
+ }
+#endif
+ else {
+ if (BUFFSIZE >= 15) {
+ memcpy(c->ssl_buff, "PROXY UNKNOWN\r\n ", 15);
+ c->ssl_ptr += 15;
+ }
+ }
+ c->sendproxy = 0;
+ }
+
/****************************** read from SSL */
if((SSL_read_wants_read && ssl_can_rd) ||
(SSL_read_wants_write && ssl_can_wr) ||
diff -ur stunnel-4.33/src/options.c stunnel-4.33.sendproxy/src/options.c
--- stunnel-4.33/src/options.c 2010-04-05 20:44:43.000000000 +0200
+++ stunnel-4.33.sendproxy/src/options.c 2010-10-15 16:51:58.706136512 +0200
@@ -792,6 +792,29 @@
}
#endif
+ /* sendproxy */
+ switch(cmd) {
+ case CMD_INIT:
+ section->option.sendproxy=0;
+ break;
+ case CMD_EXEC:
+ if(strcasecmp(opt, "sendproxy"))
+ break;
+ if(!strcasecmp(arg, "yes"))
+ section->option.sendproxy=1;
+ else if(!strcasecmp(arg, "no"))
+ section->option.sendproxy=0;
+ else
+ return "argument should be either 'yes' or 'no'";
+ return NULL; /* OK */
+ case CMD_DEFAULT:
+ break;
+ case CMD_HELP:
+ s_log(LOG_NOTICE, "%-15s = yes|no append proxy prefix",
+ "sendproxy");
+ break;
+ }
+
/* exec */
switch(cmd) {
case CMD_INIT:
diff -ur stunnel-4.33/src/prototypes.h stunnel-4.33.sendproxy/src/prototypes.h
--- stunnel-4.33/src/prototypes.h 2010-04-04 20:34:27.000000000 +0200
+++ stunnel-4.33.sendproxy/src/prototypes.h 2010-10-15 16:56:35.129137473 +0200
@@ -178,6 +178,7 @@
unsigned int retry:1; /* loop remote+program */
unsigned int sessiond:1;
unsigned int program:1;
+ unsigned int sendproxy:1;
#ifndef USE_WIN32
unsigned int pty:1;
unsigned int transparent:1;
@@ -346,6 +347,7 @@
char sock_buff[BUFFSIZE]; /* socket read buffer */
char ssl_buff[BUFFSIZE]; /* SSL read buffer */
+ int sendproxy;
int sock_ptr, ssl_ptr; /* index of first unused byte in buffer */
FD *sock_rfd, *sock_wfd; /* read and write socket descriptors */
FD *ssl_rfd, *ssl_wfd; /* read and write SSL descriptors */
I am well aware of the popular opinion that such subjects are too abstruse to be understood by practical mechanics—an assumption that is founded mainly in the fact that the subject of heat and motion are not generally studied, and have been too recently demonstrated in a scientific way to command confidence and attention; but the subject is really no more difficult to understand in an elementary sense than that of the relation between movement and force illustrated in the "mechanical powers" of school-books, which no apprentice ever did or ever will understand, except by first studying the principles of force and motion, independent of mechanical agents, such as screws, levers, wedges, and so on. A new design should be based upon one of two suppositions—either that existing mechanism is imperfect in its construction, or that it lacks functions which a new design may supply; and if those who spend their time in making plans for novel machinery would stop to consider this from the beginning, it would save no little of the time wasted in what may be called scheming without a purpose. A man, coming silently from some concealment, in a dory, undetected in their busy absorption, held something menacingly businesslike and sending sun glints from its blue steel. Its hollow nose covered both at the range he had. “Well, Sky Patrol—and Ground Crew,” he hailed them. “We are going to see some excitement at last!” "You're right, Si," shouted the Lieutenant and Shorty. "Hip, hip, hooray for the Army o' the Cumberland and old Pap Thomas!" "Glad ain't no name for it," said Levi. "Did you say you'd got the boys in there? Here, you men, bring me two or three of those cracker-boxes." "The very same company," gasped the woman. And the other asked: "And the raid'll be made ter-morrer?" "My—" But before they had time to answer, something burst from between the stalls and ran down the darkling slope, brandishing a knife. It was Mexico Bill, running amok, as he had sometimes run before, but on less crowded occasions. The women sent up an ear-splitting yell, and made a fresh onslaught on the hedge. Someone grabbed the half-breed from behind, but his knife flashed, and the next moment he was free, dashing through the gorse towards his victims. Such a discovery could not long remain a secret;—the tale reached the ears of young De Boteler, and, already prepossessed in his favour, it was but a natural consequence that Calverley should rise from being first an assistant, to be the steward, the page, and, at length, the esquire to the heir to the barony of Sudley. But the progress of his fortunes did but add to the malevolence of the detractor and the tale-bearer; theft, sacrilege, and even murder were hinted at as probable causes for a youth, who evidently did not belong to the vulgar, being thus a friendless outcast. But the most charitable surmise was, that he was the offspring of the unhallowed love of some dame or damsel who had reared him in privacy, and had destined him for the church; and that either upon the death of his protectress, or through some fault, he had been expelled from his home. Calverley had a distant authoritative manner towards his equals and inferiors, which, despite every effort, checked inquisitiveness; and all the information he ever gave was, that he was the son of a respectable artizan of the city of London, whom his father's death had left friendless. Whether this statement was correct or not, could never be discovered. Calverley was never known to allude to aught that happened in the years previous to his becoming an inmate of the castle: what little he had said was merely in reply to direct questions. It would seem, then, that he stood alone in the world, and such a situation is by no means enviable; and although duplicity, selfishness and tyranny, formed the principal traits in his character; and though independently of tyranny and selfishness, his mind instinctively shrunk from any contact, save that of necessity, with those beneath him, yet had he gazed upon the growing beauty of Margaret till a love pure and deep—a love in which was concentrated all the slumbering affections, had risen and expanded in his breast, until it had, as it were, become a part of his being. HoMEA一级日本l00免费看
ENTER NUMBET 0018www.bjjc2008.com.cn
b019.com.cn
www.s3lmknj5.com.cn
kurogane.com.cn
mshi.net.cn
hy-qd.com.cn
tpjv.com.cn
xbmusic.com.cn
www.tianfu5.com.cn
swbus.com.cn