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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
|
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include "stream_base.h"
#include "stream_proxy.h"
#include "stream_entry.h"
char process_http_proxy_stream(struct streaminfo *pstream,struct streaminfo *pProxy,void * a_packet)
{
int ret=APP_STATE_GIVEME;
struct tcpdetail *pdetail=(struct tcpdetail *)pstream->pdetail;
char *data=pdetail->pdata;
struct proxydetail*pProxydetail=NULL;
pProxydetail=(struct proxydetail *)(pProxy->pdetail);
//������״ν���
if(pProxydetail==NULL)
{
pProxydetail=dictator_malloc(pstream->threadnum,sizeof(struct proxydetail));
memset(pProxydetail,0,sizeof(struct proxydetail));
pProxy->pdetail=pProxydetail;
}
if(pProxydetail->dealstate==PROXY_STATE_SEL)
{
//to do
//��ȡ������ַ��Ϣ
//��ȡ�û�������
pProxydetail->pUser=dictator_malloc(pstream->threadnum,10);
memcpy(pProxydetail->pUser,"testliuqy",10);
pProxydetail->uiUserLen=10;
//���������������Ϣ��
if(memmem(data,pdetail->datalen,"\r\n\r\n",4)!=NULL)
{
pProxydetail->dealstate=PROXY_STATE_LINK_IN;
//��������Ƕ��ϵ
/* 2014-12-29 lijia add, ���������ͱ�ʶ, TODO 1:�����socks��ôʶ��? �˺���Ӧ����һ�����Ͳ��� */
pProxy->type = STREAM_TYPE_HTTP_PROXY;
set_proxy_fstream(pstream,pProxy);
}
}
else if(pProxydetail->dealstate==PROXY_STATE_LINK_IN)
{
ret=deal_tcp_in_proxy_stream(pstream,a_packet,pProxy);
}
return ret;
}
char deal_http_proxy_stream(struct streaminfo *pstream,void **pme, int thread_seq,void *a_packet)
{
struct tcpdetail *pdetail=(struct tcpdetail *)pstream->pdetail;
struct streaminfo *pProxy=NULL;
int ret=APP_STATE_GIVEME;
if(pstream->opstate== OP_STATE_PENDING)
{
//����ʶ��ʶ�����к���ռ�
//ʶ�������
if(( pdetail->datalen >=8)&&
( (memcmp(pdetail->pdata, "connect ", 8) == 0 )
|| (memcmp(pdetail->pdata, "CONNECT ", 8) == 0 )))
{
pProxy=dictator_malloc(pstream->threadnum,sizeof(struct streaminfo));
memset(pProxy,0,sizeof(struct streaminfo));
(*pme)=pProxy;
return process_http_proxy_stream(pstream,pProxy,a_packet);
}
else
{
return APP_STATE_DROPME;
}
}
else if(pstream->opstate== OP_STATE_DATA)
{
pProxy=(struct streaminfo *)(*pme);
ret=process_http_proxy_stream(pstream,pProxy,a_packet);
if(ret==APP_STATE_DROPME)
{
free_tcp_proxy_stream(pstream,pProxy);
(*pme)=NULL;
}
}
if(pstream->opstate== OP_STATE_CLOSE)
{
if((*pme)!=NULL)
{
pProxy=(struct streaminfo *)(*pme);
pProxy->opstate=OP_STATE_CLOSE;
ret=process_http_proxy_stream(pstream,pProxy,a_packet);
free_tcp_proxy_stream(pstream,pProxy);
(*pme)=NULL;
}
}
return ret;
}
char TCP_ENTRY(struct streaminfo *a_tcp, void **pme, int thread_seq,void *a_packet)
{
return deal_http_proxy_stream(a_tcp,pme,thread_seq,a_packet);
}
int CHAR_DESTROY(void)
{
return 0;
}
int CHAR_INIT()
{
int demo_plugid = 51;
printf("test_connect init ok!!!!!!!!!!!!\n");
// ����ʵ���Զ���
// ֻҪ��������ֵΪ���ID��
return demo_plugid;
}
void TEST_GET_PLUGID(unsigned short plugid)
{
printf("proto id is %d\n",plugid);
}
long long TEST_FLAG_CHANGE(char* flag_str)
{
return 0;
}
void TEST_PROT_FUNSTAT (long long protflag)
{
return ;
}
|