Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
NetWork
Opentracker
提交
41019c79
O
Opentracker
项目概览
NetWork
/
Opentracker
通知
0
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
O
Opentracker
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
41019c79
编写于
10月 19, 2007
作者:
E
erdgeist
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Introducing multiscrape
上级
d5876ebb
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
36 addition
and
24 deletion
+36
-24
opentracker.c
opentracker.c
+16
-11
trackerlogic.c
trackerlogic.c
+19
-12
trackerlogic.h
trackerlogic.h
+1
-1
未找到文件。
opentracker.c
浏览文件 @
41019c79
...
...
@@ -61,6 +61,9 @@ static char static_inbuf[8192];
static
char
static_outbuf
[
8192
];
static
char
static_tmpbuf
[
8192
];
#define OT_MAXMULTISCRAPE_COUNT 64
static
ot_hash
multiscrape_buf
[
OT_MAXMULTISCRAPE_COUNT
];
static
char
*
FLAG_TCP
=
"TCP"
;
static
char
*
FLAG_UDP
=
"UDP"
;
static
size_t
ot_sockets_count
=
0
;
...
...
@@ -217,7 +220,7 @@ static void httpresponse( const int64 s, char *data, size_t l ) {
ot_peer
peer
;
ot_torrent
*
torrent
;
ot_hash
*
hash
=
NULL
;
int
numwant
,
tmp
,
scanon
,
mode
;
int
numwant
,
tmp
,
scanon
,
mode
,
scrape_count
;
unsigned
short
port
=
htons
(
6881
);
time_t
t
;
ssize_t
len
;
...
...
@@ -373,17 +376,18 @@ LOG_TO_STDERR( "stats: %d.%d.%d.%d - mode: s24s old\n", h->ip[0], h->ip[1], h->i
case
6
:
/* scrape ? */
if
(
byte_diff
(
data
,
6
,
"scrape"
)
)
HTTPERROR_404
;
/* We want the pure plain un-unescaped text */
memmove
(
static_tmpbuf
,
static_inbuf
,
8192
);
/* We want the pure plain un-unescaped text */
memmove
(
static_tmpbuf
,
static_inbuf
,
8192
);
/* This is to hack around stupid clients that just replace
"announce ?info_hash" with "scrape ?info_hash".
We do not want to bomb them with full scrapes */
if
(
!
byte_diff
(
c
,
2
,
" ?"
)
)
++
c
;
/* This is to hack around stupid clients that just replace
"announce ?info_hash" with "scrape ?info_hash".
We do not want to bomb them with full scrapes */
if
(
!
byte_diff
(
c
,
2
,
" ?"
)
)
c
+=
2
;
SCRAPE_WORKAROUND:
scanon
=
1
;
scrape_count
=
0
;
while
(
scanon
)
{
switch
(
scan_urlencoded_query
(
&
c
,
data
=
c
,
SCAN_SEARCHPATH_PARAM
)
)
{
case
-
2
:
scanon
=
0
;
break
;
/* TERMINATOR */
...
...
@@ -396,13 +400,14 @@ SCRAPE_WORKAROUND:
}
/* ignore this, when we have less than 20 bytes */
if
(
scan_urlencoded_query
(
&
c
,
data
=
c
,
SCAN_SEARCHPATH_VALUE
)
!=
20
)
HTTPERROR_400_PARAM
;
hash
=
(
ot_hash
*
)
data
;
if
(
scrape_count
<
OT_MAXMULTISCRAPE_COUNT
)
memmove
(
multiscrape_buf
+
scrape_count
++
,
data
,
sizeof
(
ot_hash
)
);
break
;
}
}
/* Scanned whole query string, no hash means full scrape... you might want to limit that */
if
(
!
hash
)
{
if
(
!
scrape_count
)
{
LOG_TO_STDERR
(
"scrp: %d.%d.%d.%d - FULL SCRAPE
\n
"
,
h
->
ip
[
0
],
h
->
ip
[
1
],
h
->
ip
[
2
],
h
->
ip
[
3
]
);
write
(
2
,
static_tmpbuf
,
l
);
write
(
2
,
"
\n\n\n
"
,
1
);
...
...
@@ -412,7 +417,7 @@ write( 2, "\n\n\n", 1 );
}
/* Enough for http header + whole scrape string */
if
(
!
(
reply_size
=
return_tcp_scrape_for_torrent
(
hash
,
SUCCESS_HTTP_HEADER_LENGTH
+
static_outbuf
)
)
)
HTTPERROR_500
;
if
(
!
(
reply_size
=
return_tcp_scrape_for_torrent
(
multiscrape_buf
,
scrape_count
,
SUCCESS_HTTP_HEADER_LENGTH
+
static_outbuf
)
)
)
HTTPERROR_500
;
ot_overall_tcp_successfulannounces
++
;
break
;
...
...
@@ -423,7 +428,7 @@ write( 2, "\n\n\n", 1 );
if
(
byte_diff
(
data
,
8
,
"announce"
)
)
HTTPERROR_404
;
/* This is to hack around stupid clients that send "announce ?info_hash" */
if
(
!
byte_diff
(
c
,
2
,
" ?"
)
)
++
c
;
if
(
!
byte_diff
(
c
,
2
,
" ?"
)
)
c
+=
2
;
ANNOUNCE_WORKAROUND:
...
...
trackerlogic.c
浏览文件 @
41019c79
...
...
@@ -411,23 +411,30 @@ size_t return_udp_scrape_for_torrent( ot_hash *hash, char *reply ) {
}
/* Fetches scrape info for a specific torrent */
size_t
return_tcp_scrape_for_torrent
(
ot_hash
*
hash
,
char
*
reply
)
{
size_t
return_tcp_scrape_for_torrent
(
ot_hash
*
hash
_list
,
int
amount
,
char
*
reply
)
{
char
*
r
=
reply
;
int
exactmatch
,
i
;
size_t
peers
=
0
,
seeds
=
0
;
ot_vector
*
torrents_list
=
&
all_torrents
[
*
hash
[
0
]];
ot_torrent
*
torrent
=
binary_search
(
hash
,
torrents_list
->
data
,
torrents_list
->
size
,
sizeof
(
ot_torrent
),
OT_HASH_COMPARE_SIZE
,
&
exactmatch
);
int
exactmatch
,
i
,
j
;
if
(
!
exactmatch
)
return
sprintf
(
r
,
"d5:filesdee
"
);
r
+=
sprintf
(
r
,
"d5:filesd
"
);
for
(
i
=
0
;
i
<
OT_POOLS_COUNT
;
++
i
)
{
peers
+=
torrent
->
peer_list
->
peers
[
i
].
size
;
seeds
+=
torrent
->
peer_list
->
seed_count
[
i
];
}
for
(
i
=
0
;
i
<
amount
;
++
i
)
{
ot_hash
*
hash
=
hash_list
+
i
;
ot_vector
*
torrents_list
=
&
all_torrents
[
*
hash
[
0
]];
ot_torrent
*
torrent
=
binary_search
(
hash
,
torrents_list
->
data
,
torrents_list
->
size
,
sizeof
(
ot_torrent
),
OT_HASH_COMPARE_SIZE
,
&
exactmatch
);
size_t
peers
=
0
,
seeds
=
0
;
memmove
(
r
,
"d5:filesd20:"
,
12
);
memmove
(
r
+
12
,
hash
,
20
);
r
+=
sprintf
(
r
+
32
,
"d8:completei%zde10:downloadedi%zde10:incompletei%zdeeee"
,
seeds
,
torrent
->
peer_list
->
downloaded
,
peers
-
seeds
)
+
32
;
if
(
!
exactmatch
)
continue
;
for
(
j
=
0
;
j
<
OT_POOLS_COUNT
;
++
j
)
{
peers
+=
torrent
->
peer_list
->
peers
[
j
].
size
;
seeds
+=
torrent
->
peer_list
->
seed_count
[
j
];
}
memmove
(
r
,
"20:"
,
3
);
memmove
(
r
+
3
,
hash
,
20
);
r
+=
sprintf
(
r
+
23
,
"d8:completei%zde10:downloadedi%zde10:incompletei%zdee"
,
seeds
,
torrent
->
peer_list
->
downloaded
,
peers
-
seeds
)
+
23
;
}
*
r
++
=
'e'
;
*
r
++
=
'e'
;
return
r
-
reply
;
}
...
...
trackerlogic.h
浏览文件 @
41019c79
...
...
@@ -94,7 +94,7 @@ ot_torrent *add_peer_to_torrent( ot_hash *hash, ot_peer *peer, int from_changese
size_t
remove_peer_from_torrent
(
ot_hash
*
hash
,
ot_peer
*
peer
,
char
*
reply
,
int
is_tcp
);
size_t
return_peers_for_torrent
(
ot_torrent
*
torrent
,
size_t
amount
,
char
*
reply
,
int
is_tcp
);
size_t
return_fullscrape_for_tracker
(
char
**
reply
);
size_t
return_tcp_scrape_for_torrent
(
ot_hash
*
hash
,
char
*
reply
);
size_t
return_tcp_scrape_for_torrent
(
ot_hash
*
hash
,
int
amount
,
char
*
reply
);
size_t
return_udp_scrape_for_torrent
(
ot_hash
*
hash
,
char
*
reply
);
size_t
return_stats_for_tracker
(
char
*
reply
,
int
mode
);
size_t
return_stats_for_slash24s
(
char
*
reply
,
size_t
amount
,
ot_dword
thresh
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录