亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? proxy.c

?? 遠程登陸工具軟件源碼 用于遠程登陸unix
?? C
?? 第 1 頁 / 共 3 頁
字號:
	if (data[off] == '\n') {
	    /* we have a newline */
	    off++;

	    /* is that the only thing on this line? */
	    if (off <= 2) return off;

	    /* if not, then there is the possibility that this header
	     * continues onto the next line, if it starts with a space
	     * or a tab.
	     */

	    if (off + 1 < len &&
		data[off+1] != ' ' &&
		data[off+1] != '\t') return off;

	    /* the line does continue, so we have to keep going
	     * until we see an the header's "real" end of line.
	     */
	    off++;
	}

	off++;
    }

    return -1;
}

int proxy_http_negotiate (Proxy_Socket p, int change)
{
    if (p->state == PROXY_STATE_NEW) {
	/* we are just beginning the proxy negotiate process,
	 * so we'll send off the initial bits of the request.
	 * for this proxy method, it's just a simple HTTP
	 * request
	 */
	char *buf, dest[512];

	sk_getaddr(p->remote_addr, dest, lenof(dest));

	buf = dupprintf("CONNECT %s:%i HTTP/1.1\r\nHost: %s:%i\r\n",
			dest, p->remote_port, dest, p->remote_port);
	sk_write(p->sub_socket, buf, strlen(buf));
	sfree(buf);

	if (p->cfg.proxy_username[0] || p->cfg.proxy_password[0]) {
	    char buf[sizeof(p->cfg.proxy_username)+sizeof(p->cfg.proxy_password)];
	    char buf2[sizeof(buf)*4/3 + 100];
	    int i, j, len;
	    sprintf(buf, "%s:%s", p->cfg.proxy_username, p->cfg.proxy_password);
	    len = strlen(buf);
	    sprintf(buf2, "Proxy-Authorization: Basic ");
	    for (i = 0, j = strlen(buf2); i < len; i += 3, j += 4)
		base64_encode_atom((unsigned char *)(buf+i),
				   (len-i > 3 ? 3 : len-i), buf2+j);
	    strcpy(buf2+j, "\r\n");
	    sk_write(p->sub_socket, buf2, strlen(buf2));
	}

	sk_write(p->sub_socket, "\r\n", 2);

	p->state = 1;
	return 0;
    }

    if (change == PROXY_CHANGE_CLOSING) {
	/* if our proxy negotiation process involves closing and opening
	 * new sockets, then we would want to intercept this closing
	 * callback when we were expecting it. if we aren't anticipating
	 * a socket close, then some error must have occurred. we'll
	 * just pass those errors up to the backend.
	 */
	return plug_closing(p->plug, p->closing_error_msg,
			    p->closing_error_code,
			    p->closing_calling_back);
    }

    if (change == PROXY_CHANGE_SENT) {
	/* some (or all) of what we wrote to the proxy was sent.
	 * we don't do anything new, however, until we receive the
	 * proxy's response. we might want to set a timer so we can
	 * timeout the proxy negotiation after a while...
	 */
	return 0;
    }

    if (change == PROXY_CHANGE_ACCEPTING) {
	/* we should _never_ see this, as we are using our socket to
	 * connect to a proxy, not accepting inbound connections.
	 * what should we do? close the socket with an appropriate
	 * error message?
	 */
	return plug_accepting(p->plug, p->accepting_sock);
    }

    if (change == PROXY_CHANGE_RECEIVE) {
	/* we have received data from the underlying socket, which
	 * we'll need to parse, process, and respond to appropriately.
	 */

	char *data, *datap;
	int len;
	int eol;

	if (p->state == 1) {

	    int min_ver, maj_ver, status;

	    /* get the status line */
	    len = bufchain_size(&p->pending_input_data);
	    assert(len > 0);	       /* or we wouldn't be here */
	    data = snewn(len+1, char);
	    bufchain_fetch(&p->pending_input_data, data, len);
	    /*
	     * We must NUL-terminate this data, because Windows
	     * sscanf appears to require a NUL at the end of the
	     * string because it strlens it _first_. Sigh.
	     */
	    data[len] = '\0';

	    eol = get_line_end(data, len);
	    if (eol < 0) {
		sfree(data);
		return 1;
	    }

	    status = -1;
	    /* We can't rely on whether the %n incremented the sscanf return */
	    if (sscanf((char *)data, "HTTP/%i.%i %n",
		       &maj_ver, &min_ver, &status) < 2 || status == -1) {
		plug_closing(p->plug, "Proxy error: HTTP response was absent",
			     PROXY_ERROR_GENERAL, 0);
		sfree(data);
		return 1;
	    }

	    /* remove the status line from the input buffer. */
	    bufchain_consume(&p->pending_input_data, eol);
	    if (data[status] != '2') {
		/* error */
		char *buf;
		data[eol] = '\0';
		while (eol > status &&
		       (data[eol-1] == '\r' || data[eol-1] == '\n'))
		    data[--eol] = '\0';
		buf = dupprintf("Proxy error: %s", data+status);
		plug_closing(p->plug, buf, PROXY_ERROR_GENERAL, 0);
		sfree(buf);
		sfree(data);
		return 1;
	    }

	    sfree(data);

	    p->state = 2;
	}

	if (p->state == 2) {

	    /* get headers. we're done when we get a
	     * header of length 2, (ie. just "\r\n")
	     */

	    len = bufchain_size(&p->pending_input_data);
	    assert(len > 0);	       /* or we wouldn't be here */
	    data = snewn(len, char);
	    datap = data;
	    bufchain_fetch(&p->pending_input_data, data, len);

	    eol = get_line_end(datap, len);
	    if (eol < 0) {
		sfree(data);
		return 1;
	    }
	    while (eol > 2)
	    {
		bufchain_consume(&p->pending_input_data, eol);
		datap += eol;
		len   -= eol;
		eol = get_line_end(datap, len);
	    }

	    if (eol == 2) {
		/* we're done */
		bufchain_consume(&p->pending_input_data, 2);
		proxy_activate(p);
		/* proxy activate will have dealt with
		 * whatever is left of the buffer */
		sfree(data);
		return 1;
	    }

	    sfree(data);
	    return 1;
	}
    }

    plug_closing(p->plug, "Proxy error: unexpected proxy error",
		 PROXY_ERROR_UNEXPECTED, 0);
    return 1;
}

/* ----------------------------------------------------------------------
 * SOCKS proxy type.
 */

/* SOCKS version 4 */
int proxy_socks4_negotiate (Proxy_Socket p, int change)
{
    if (p->state == PROXY_CHANGE_NEW) {

	/* request format:
	 *  version number (1 byte) = 4
	 *  command code (1 byte)
	 *    1 = CONNECT
	 *    2 = BIND
	 *  dest. port (2 bytes) [network order]
	 *  dest. address (4 bytes)
	 *  user ID (variable length, null terminated string)
	 */

	int length, type, namelen;
	char *command, addr[4], hostname[512];

	type = sk_addrtype(p->remote_addr);
	if (type == ADDRTYPE_IPV6) {
	    plug_closing(p->plug, "Proxy error: SOCKS version 4 does"
			 " not support IPv6", PROXY_ERROR_GENERAL, 0);
	    return 1;
	} else if (type == ADDRTYPE_IPV4) {
	    namelen = 0;
	    sk_addrcopy(p->remote_addr, addr);
	} else {		       /* type == ADDRTYPE_NAME */
	    assert(type == ADDRTYPE_NAME);
	    sk_getaddr(p->remote_addr, hostname, lenof(hostname));
	    namelen = strlen(hostname) + 1;   /* include the NUL */
	    addr[0] = addr[1] = addr[2] = 0;
	    addr[3] = 1;
	}

	length = strlen(p->cfg.proxy_username) + namelen + 9;
	command = snewn(length, char);
	strcpy(command + 8, p->cfg.proxy_username);

	command[0] = 4; /* version 4 */
	command[1] = 1; /* CONNECT command */

	/* port */
	command[2] = (char) (p->remote_port >> 8) & 0xff;
	command[3] = (char) p->remote_port & 0xff;

	/* address */
	memcpy(command + 4, addr, 4);

	/* hostname */
	memcpy(command + 8 + strlen(p->cfg.proxy_username) + 1,
	       hostname, namelen);

	sk_write(p->sub_socket, command, length);
	sfree(command);

	p->state = 1;
	return 0;
    }

    if (change == PROXY_CHANGE_CLOSING) {
	/* if our proxy negotiation process involves closing and opening
	 * new sockets, then we would want to intercept this closing
	 * callback when we were expecting it. if we aren't anticipating
	 * a socket close, then some error must have occurred. we'll
	 * just pass those errors up to the backend.
	 */
	return plug_closing(p->plug, p->closing_error_msg,
			    p->closing_error_code,
			    p->closing_calling_back);
    }

    if (change == PROXY_CHANGE_SENT) {
	/* some (or all) of what we wrote to the proxy was sent.
	 * we don't do anything new, however, until we receive the
	 * proxy's response. we might want to set a timer so we can
	 * timeout the proxy negotiation after a while...
	 */
	return 0;
    }

    if (change == PROXY_CHANGE_ACCEPTING) {
	/* we should _never_ see this, as we are using our socket to
	 * connect to a proxy, not accepting inbound connections.
	 * what should we do? close the socket with an appropriate
	 * error message?
	 */
	return plug_accepting(p->plug, p->accepting_sock);
    }

    if (change == PROXY_CHANGE_RECEIVE) {
	/* we have received data from the underlying socket, which
	 * we'll need to parse, process, and respond to appropriately.
	 */

	if (p->state == 1) {
	    /* response format:
	     *  version number (1 byte) = 4
	     *  reply code (1 byte)
	     *    90 = request granted
	     *    91 = request rejected or failed
	     *    92 = request rejected due to lack of IDENTD on client
	     *    93 = request rejected due to difference in user ID 
	     *         (what we sent vs. what IDENTD said)
	     *  dest. port (2 bytes)
	     *  dest. address (4 bytes)
	     */

	    char data[8];

	    if (bufchain_size(&p->pending_input_data) < 8)
		return 1;	       /* not got anything yet */
	    
	    /* get the response */
	    bufchain_fetch(&p->pending_input_data, data, 8);

	    if (data[0] != 0) {
		plug_closing(p->plug, "Proxy error: SOCKS proxy responded with "
				      "unexpected reply code version",
			     PROXY_ERROR_GENERAL, 0);
		return 1;
	    }

	    if (data[1] != 90) {

		switch (data[1]) {
		  case 92:
		    plug_closing(p->plug, "Proxy error: SOCKS server wanted IDENTD on client",
				 PROXY_ERROR_GENERAL, 0);
		    break;
		  case 93:
		    plug_closing(p->plug, "Proxy error: Username and IDENTD on client don't agree",
				 PROXY_ERROR_GENERAL, 0);
		    break;
		  case 91:
		  default:
		    plug_closing(p->plug, "Proxy error: Error while communicating with proxy",
				 PROXY_ERROR_GENERAL, 0);
		    break;
		}

		return 1;
	    }
	    bufchain_consume(&p->pending_input_data, 8);

	    /* we're done */
	    proxy_activate(p);
	    /* proxy activate will have dealt with
	     * whatever is left of the buffer */
	    return 1;
	}
    }

    plug_closing(p->plug, "Proxy error: unexpected proxy error",
		 PROXY_ERROR_UNEXPECTED, 0);
    return 1;
}

/* SOCKS version 5 */
int proxy_socks5_negotiate (Proxy_Socket p, int change)
{
    if (p->state == PROXY_CHANGE_NEW) {

	/* initial command:
	 *  version number (1 byte) = 5
	 *  number of available authentication methods (1 byte)
	 *  available authentication methods (1 byte * previous value)
	 *    authentication methods:
	 *     0x00 = no authentication
	 *     0x01 = GSSAPI
	 *     0x02 = username/password
	 *     0x03 = CHAP
	 */

	char command[4];
	int len;

	command[0] = 5; /* version 5 */
	if (p->cfg.proxy_username[0] || p->cfg.proxy_password[0]) {
	    command[1] = 2;	       /* two methods supported: */
	    command[2] = 0x00;	       /* no authentication */
	    command[3] = 0x02;	       /* username/password */
	    len = 4;
	} else {
	    command[1] = 1;	       /* one methods supported: */
	    command[2] = 0x00;	       /* no authentication */
	    len = 3;
	}

	sk_write(p->sub_socket, command, len);

	p->state = 1;
	return 0;
    }

    if (change == PROXY_CHANGE_CLOSING) {
	/* if our proxy negotiation process involves closing and opening
	 * new sockets, then we would want to intercept this closing
	 * callback when we were expecting it. if we aren't anticipating
	 * a socket close, then some error must have occurred. we'll
	 * just pass those errors up to the backend.
	 */
	return plug_closing(p->plug, p->closing_error_msg,
			    p->closing_error_code,
			    p->closing_calling_back);
    }

    if (change == PROXY_CHANGE_SENT) {
	/* some (or all) of what we wrote to the proxy was sent.
	 * we don't do anything new, however, until we receive the
	 * proxy's response. we might want to set a timer so we can
	 * timeout the proxy negotiation after a while...
	 */
	return 0;
    }

    if (change == PROXY_CHANGE_ACCEPTING) {
	/* we should _never_ see this, as we are using our socket to
	 * connect to a proxy, not accepting inbound connections.
	 * what should we do? close the socket with an appropriate
	 * error message?
	 */
	return plug_accepting(p->plug, p->accepting_sock);
    }

    if (change == PROXY_CHANGE_RECEIVE) {
	/* we have received data from the underlying socket, which
	 * we'll need to parse, process, and respond to appropriately.
	 */

	if (p->state == 1) {

	    /* initial response:
	     *  version number (1 byte) = 5
	     *  authentication method (1 byte)
	     *    authentication methods:
	     *     0x00 = no authentication
	     *     0x01 = GSSAPI
	     *     0x02 = username/password 
	     *     0x03 = CHAP
	     *     0xff = no acceptable methods
	     */
	    char data[2];

	    if (bufchain_size(&p->pending_input_data) < 2)
		return 1;	       /* not got anything yet */

	    /* get the response */
	    bufchain_fetch(&p->pending_input_data, data, 2);

	    if (data[0] != 5) {
		plug_closing(p->plug, "Proxy error: SOCKS proxy returned unexpected version",
			     PROXY_ERROR_GENERAL, 0);
		return 1;
	    }

	    if (data[1] == 0x00) p->state = 2; /* no authentication needed */
	    else if (data[1] == 0x01) p->state = 4; /* GSSAPI authentication */
	    else if (data[1] == 0x02) p->state = 5; /* username/password authentication */
	    else if (data[1] == 0x03) p->state = 6; /* CHAP authentication */
	    else {
		plug_closing(p->plug, "Proxy error: SOCKS proxy did not accept our authentication",
			     PROXY_ERROR_GENERAL, 0);
		return 1;
	    }
	    bufchain_consume(&p->pending_input_data, 2);
	}

	if (p->state == 7) {

	    /* password authentication reply format:
	     *  version number (1 bytes) = 1
	     *  reply code (1 byte)
	     *    0 = succeeded
	     *    >0 = failed
	     */
	    char data[2];

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
精品国产一区二区三区忘忧草| 欧美tickling网站挠脚心| 欧美三级电影网| 欧美国产精品中文字幕| 日韩不卡免费视频| 色欧美88888久久久久久影院| 2020国产精品| 日产欧产美韩系列久久99| 91网上在线视频| 国产日韩av一区| 国产麻豆视频精品| 日韩欧美国产精品一区| 午夜亚洲国产au精品一区二区| 99久久综合99久久综合网站| 欧美精品一区男女天堂| 美女尤物国产一区| 欧美一级搡bbbb搡bbbb| 婷婷综合久久一区二区三区| 色美美综合视频| 亚洲毛片av在线| aaa国产一区| 国产精品久久久久久久蜜臀| 国产成人精品影院| 国产精品无遮挡| 成人免费视频一区| 国产精品视频第一区| 国产成人精品免费一区二区| 久久久国产精华| 国产盗摄视频一区二区三区| 国产亚洲精品免费| 成人晚上爱看视频| 综合分类小说区另类春色亚洲小说欧美 | 日韩视频免费直播| 蜜臀99久久精品久久久久久软件| 欧美日高清视频| 免费成人在线视频观看| 日韩亚洲欧美综合| 精品一区二区三区的国产在线播放| 欧美大片顶级少妇| 国产麻豆成人传媒免费观看| 国产网站一区二区| 99综合电影在线视频| 亚洲摸摸操操av| 欧美日韩国产区一| 奇米精品一区二区三区在线观看| 26uuu亚洲婷婷狠狠天堂| 国产乱子伦一区二区三区国色天香| 久久久五月婷婷| 95精品视频在线| 亚洲成人7777| 国产亚洲一二三区| 91视频在线看| 免费在线视频一区| 亚洲国产精品黑人久久久| 99久久精品情趣| 99久久99久久精品国产片果冻| 中文字幕五月欧美| 欧美午夜在线观看| 国产在线视视频有精品| 国产精品久久午夜| 精品1区2区3区| 国产在线播放一区| 一区二区三区欧美日韩| 日韩三级视频在线看| 不卡电影一区二区三区| 午夜婷婷国产麻豆精品| 中文字幕不卡三区| 91精品国产一区二区三区蜜臀 | 亚洲成人免费视频| 久久人人爽人人爽| 欧美日韩午夜影院| 成人免费视频播放| 秋霞电影一区二区| 一区二区视频免费在线观看| 精品国产一区二区亚洲人成毛片| 色哟哟国产精品免费观看| 黑人精品欧美一区二区蜜桃| 亚洲国产精品麻豆| 国产欧美精品一区aⅴ影院| 欧美日韩一级二级| caoporen国产精品视频| 久久99精品久久只有精品| 亚洲大型综合色站| 亚洲欧美日韩国产一区二区三区 | 亚洲一区中文在线| 亚洲国产激情av| 欧美电影免费观看完整版| 欧美色国产精品| 91污片在线观看| 成人av在线一区二区| 韩国女主播成人在线观看| 欧美aⅴ一区二区三区视频| 一区二区三区四区在线播放| 国产欧美精品一区二区三区四区| 精品三级av在线| 91精品一区二区三区在线观看| 91视频在线观看| www.亚洲精品| 国产成人在线看| 狠狠色狠狠色合久久伊人| 蜜芽一区二区三区| 肉丝袜脚交视频一区二区| 亚洲精品乱码久久久久久 | 99精品欧美一区| 成人美女视频在线观看18| 国产一区视频导航| 国产精品亚洲人在线观看| 国模套图日韩精品一区二区| 久久激五月天综合精品| 日本在线播放一区二区三区| 亚洲成人资源在线| 丝袜美腿亚洲综合| 日产国产欧美视频一区精品| 日韩成人精品在线观看| 久草中文综合在线| 韩国精品主播一区二区在线观看| 精品一区二区在线观看| 国产一区二区在线电影| 国产一区免费电影| 风间由美中文字幕在线看视频国产欧美| 国产一区二区精品久久91| 国产乱码精品一区二区三区av | 欧美变态口味重另类| 精品99久久久久久| 国产欧美日韩在线| 亚洲色图19p| 午夜精品福利在线| 久久国产麻豆精品| 成人毛片视频在线观看| 日本乱人伦aⅴ精品| 欧美日高清视频| 久久亚洲一区二区三区四区| 日本一区二区三区久久久久久久久不| 国产精品久久久久影院色老大 | 国产精品久久久久久久第一福利 | 91精品国产一区二区| 久久影院午夜片一区| 亚洲欧美视频一区| 午夜成人免费视频| 久久99国产乱子伦精品免费| 国产成人精品免费| 欧美午夜片在线看| 精品国产伦一区二区三区观看体验 | 欧美亚洲高清一区二区三区不卡| 在线观看一区二区精品视频| 欧美日韩精品免费| 国产日韩成人精品| 亚洲第一会所有码转帖| 国产在线不卡一卡二卡三卡四卡| av资源站一区| 日韩视频国产视频| 亚洲乱码精品一二三四区日韩在线| 午夜伦欧美伦电影理论片| 国产精品自产自拍| 欧美精品vⅰdeose4hd| 欧美国产精品中文字幕| 日韩国产欧美在线观看| 99热99精品| 久久午夜色播影院免费高清| 尤物av一区二区| 国产激情视频一区二区三区欧美 | 亚洲小少妇裸体bbw| 国产激情精品久久久第一区二区| 欧美午夜宅男影院| 国产精品人人做人人爽人人添| 日本sm残虐另类| 在线国产电影不卡| 国产精品成人免费在线| 久久99久久99| 91精品国产麻豆| 夜色激情一区二区| 成人动漫一区二区三区| wwww国产精品欧美| 青青草一区二区三区| 在线免费观看视频一区| 中文字幕一区二区三区视频| 国产一区二区精品久久99| 欧美大片在线观看一区| 图片区小说区区亚洲影院| 91行情网站电视在线观看高清版| 国产农村妇女毛片精品久久麻豆| 热久久免费视频| 欧美日本在线一区| 亚洲一区二区三区中文字幕| 97久久精品人人做人人爽50路| 久久久亚洲精品一区二区三区| 捆绑调教一区二区三区| 91麻豆精品国产| 天堂成人国产精品一区| 欧美日韩一区视频| 亚洲va韩国va欧美va| 欧美少妇bbb| 视频在线在亚洲| 91精品久久久久久久99蜜桃 | 极品少妇xxxx精品少妇偷拍 | 亚洲色图在线视频| 色婷婷综合中文久久一本| 亚洲欧美国产毛片在线| 色94色欧美sute亚洲线路一ni| 亚洲柠檬福利资源导航|