本文整理汇总了C++中routerset_new函数的典型用法代码示例。如果您正苦于以下问题:C++ routerset_new函数的具体用法?C++ routerset_new怎么用?C++ routerset_new使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了routerset_new函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: NS
static void
NS(test_main)(void *arg)
{
routerset_t *set, *bad_set;
(void)arg;
set = routerset_new();
bad_set = routerset_new();
smartlist_free(bad_set->list);
bad_set->list = NULL;
NS_MOCK(smartlist_new);
routerset_union(set, NULL);
tt_int_op(CALLED(smartlist_new), ==, 0);
routerset_union(set, bad_set);
tt_int_op(CALLED(smartlist_new), ==, 0);
done:
NS_UNMOCK(smartlist_new);
routerset_free(set);
/* Just recreate list, so we can simply use routerset_free. */
bad_set->list = smartlist_new();
routerset_free(bad_set);
}
开发者ID:caofangkun,项目名称:tor,代码行数:27,代码来源:test_routerset.c
示例2: refreshBannedNodes
void refreshBannedNodes(void)
{ r1=tmpOptions->ExcludeExitNodes;
r2=routerset_new();
char *tmp1=tor_malloc(65536),*tmp2,*tmp3;tmp2=tmp1;tmp3=tmp1;GetDlgItemText(hDlgRouterRestrictions,15100,tmp1,65536);
while(*tmp1)
{ while((*tmp1==32)||(*tmp1==9)) tmp1++;
if((*tmp1==13)||(*tmp1==10))
{ while((*tmp1==13)||(*tmp1==10)){ tmp1++;}
*tmp2++=',';
}
else if((*tmp1=='[')&&(*(tmp1+2)==']'))
{ if((*(tmp1+1)=='x')||(*(tmp1+1)=='X'))
{ tmp1+=3;
while((*tmp1==32)||(*tmp1==9)) tmp1++;
while((*tmp1!=0)&&(*tmp1!=13)&&(*tmp1!=10)) *tmp2++=*tmp1++;
}
else
while((*tmp1!=0)&&(*tmp1!=13)&&(*tmp1!=10)) tmp1++;
}
else
while((*tmp1!=0)&&(*tmp1!=13)&&(*tmp1!=10)) tmp1++;
}
*tmp2=0;routerset_parse(r2,tmp3,"ExcludeExitNodes");
tmpOptions->ExcludeExitNodes=r2;
if(r1) routerset_free(r1);
r1=tmpOptions->ExcludeNodes;
r2=routerset_new();
tmp1=tmp3;tmp2=tmp3;GetDlgItemText(hDlgRouterRestrictions,15100,tmp1,65536);
while(*tmp1)
{ while((*tmp1==32)||(*tmp1==9)) tmp1++;
if((*tmp1==13)||(*tmp1==10))
{ while((*tmp1==13)||(*tmp1==10)){ tmp1++;}
*tmp2++=',';
}
else if((*tmp1=='[')&&(*(tmp1+2)==']'))
{ if((*(tmp1+1)=='x')||(*(tmp1+1)=='X'))
{ while((*tmp1!=0)&&(*tmp1!=13)&&(*tmp1!=10)) tmp1++;
}
else
{ while((*tmp1!=0)&&(*tmp1!=13)&&(*tmp1!=10)) *tmp2++=*tmp1++;
}
}
else
{ while((*tmp1!=0)&&(*tmp1!=13)&&(*tmp1!=10)) *tmp2++=*tmp1++;
}
}
*tmp2=0;routerset_parse(r2,tmp3,"ExcludeNodes");
tmpOptions->ExcludeNodes=r2;
if(r1) routerset_free(r1);
if(tmpOptions->ExcludeExitNodes || tmpOptions->ExcludeNodes)
{ r2 = tmpOptions->_ExcludeExitNodesUnion;
r1 = routerset_new();
routerset_union(r1,tmpOptions->ExcludeExitNodes);
routerset_union(r1,tmpOptions->ExcludeNodes);
tmpOptions->_ExcludeExitNodesUnion = r1;
if(r2) routerset_free(r2);
}
tor_free(tmp3);
}
开发者ID:madnessw,项目名称:thesnow,代码行数:59,代码来源:dlg_routerres.c
示例3: refreshFavoriteNodes
void refreshFavoriteNodes(void)
{ r1=tmpOptions->EntryNodes;
r2=routerset_new();
char *tmp1=tor_malloc(65536),*tmp2,*tmp3;tmp2=tmp1;tmp3=tmp1;GetDlgItemText(hDlgRouterRestrictions,15101,tmp1,65536);
while(*tmp1)
{ while((*tmp1==32)||(*tmp1==9)) tmp1++;
if((*tmp1==13)||(*tmp1==10))
{ while((*tmp1==13)||(*tmp1==10)){ tmp1++;}
*tmp2++=',';
}
else if((*tmp1=='[')&&(*(tmp1+2)==']'))
{ if((*(tmp1+1)=='e')||(*(tmp1+1)=='E'))
{ tmp1+=3;
while((*tmp1==32)||(*tmp1==9)) tmp1++;
while((*tmp1!=0)&&(*tmp1!=13)&&(*tmp1!=10)) *tmp2++=*tmp1++;
}
else
while((*tmp1!=0)&&(*tmp1!=13)&&(*tmp1!=10)) tmp1++;
}
else
while((*tmp1!=0)&&(*tmp1!=13)&&(*tmp1!=10)) tmp1++;
}
*tmp2=0;routerset_parse(r2,tmp3,"EntryNodes");
tmpOptions->EntryNodes=r2;
if(r1) routerset_free(r1);
r1=tmpOptions->ExitNodes;
r2=routerset_new();
tmp1=tmp3;tmp2=tmp3;GetDlgItemText(hDlgRouterRestrictions,15101,tmp1,65536);
while(*tmp1)
{ while((*tmp1==32)||(*tmp1==9)) tmp1++;
if((*tmp1==13)||(*tmp1==10))
{ while((*tmp1==13)||(*tmp1==10)){ tmp1++;}
*tmp2++=',';
}
else if((*tmp1=='[')&&(*(tmp1+2)==']'))
{ if((*(tmp1+1)=='e')||(*(tmp1+1)=='E'))
{ while((*tmp1!=0)&&(*tmp1!=13)&&(*tmp1!=10)) tmp1++;
}
else if((*(tmp1+1)=='x')||(*(tmp1+1)=='X'))
{ tmp1+=3;
while((*tmp1==32)||(*tmp1==9)) tmp1++;
while((*tmp1!=0)&&(*tmp1!=13)&&(*tmp1!=10)) *tmp2++=*tmp1++;
}
else
{ while((*tmp1!=0)&&(*tmp1!=13)&&(*tmp1!=10)) *tmp2++=*tmp1++;
}
}
else
{ while((*tmp1!=0)&&(*tmp1!=13)&&(*tmp1!=10)) *tmp2++=*tmp1++;
}
}
*tmp2=0;routerset_parse(r2,tmp3,"ExitNodes");
tmpOptions->ExitNodes=r2;
if(r1) routerset_free(r1);
tor_free(tmp3);
}
开发者ID:madnessw,项目名称:thesnow,代码行数:56,代码来源:dlg_routerres.c
示例4: add_router_to_favorites
void add_router_to_favorites(HWND hDlg,char *router,char favtype)
{ if(hDlgRouterRestrictions)
{ char *favtmp2,*favtmp3;
int favtmpsize;
int i;
favtmpsize=SendDlgItemMessage(hDlgRouterRestrictions,15101,WM_GETTEXTLENGTH,0,0);
favtmp2=tor_malloc(favtmpsize+256+5);favtmp3=favtmp2;
GetDlgItemText(hDlgRouterRestrictions,15101,favtmp2,favtmpsize+1);favtmp2+=favtmpsize;
if((favtmpsize>2)&&((*(favtmp2-1)!=0x0d)&&(*(favtmp2-1)!=0x0a)))
{ *favtmp2++=0x0d;*favtmp2++=0x0a;}
*favtmp2++='[';*favtmp2++=favtype;*favtmp2++=']';*favtmp2++=32;
for(i=0;router[i];i++) *favtmp2++=router[i];
*favtmp2++=13;*favtmp2++=10;*favtmp2++=0;
tor_snprintf(favtmp2,100,get_lang_str(LANG_MB_FAV_ADDED),favtmp3+favtmpsize);
LangMessageBox(hDlg,favtmp2,LANG_MB_FAVORITES,MB_OK);
log(LOG_NOTICE,LD_APP,favtmp2);
SetDlgItemText(hDlgRouterRestrictions,15101,favtmp3);
refreshFavoriteNodes();
tor_free(favtmp3);
}
else if(favtype=='X')
{ char *tmp1=routerset_to_string(tmpOptions->ExitNodes);
int i=strlen(tmp1)+256+5;
char *tmp2=tor_malloc(i),*tmp3=tor_malloc(256);
tor_snprintf(tmp2,i,"%s,%s",tmp1,router);
r1=tmpOptions->ExitNodes;
r2=routerset_new();
routerset_parse(r2,tmp2,"ExitNodes");
tmpOptions->ExitNodes=r2;
if(r1) routerset_free(r1);
tor_snprintf(tmp3,256,"[X] %s",router);
tor_snprintf(tmp2,100,get_lang_str(LANG_MB_FAV_ADDED),tmp3);
LangMessageBox(hDlg,tmp2,LANG_MB_FAVORITES,MB_OK);
log(LOG_NOTICE,LD_APP,tmp2);
tor_free(tmp1);tor_free(tmp2);tor_free(tmp3);
}
else if(favtype=='E')
{ char *tmp1=routerset_to_string(tmpOptions->EntryNodes);
int i=strlen(tmp1)+256+5;
char *tmp2=tor_malloc(i),*tmp3=tor_malloc(256);
tor_snprintf(tmp2,i,"%s,%s",tmp1,router);
r1=tmpOptions->EntryNodes;
r2=routerset_new();
routerset_parse(r2,tmp2,"EntryNodes");
tmpOptions->EntryNodes=r2;
if(r1) routerset_free(r1);
tor_snprintf(tmp3,256,"[E] %s",router);
tor_snprintf(tmp2,100,get_lang_str(LANG_MB_FAV_ADDED),tmp3);
LangMessageBox(hDlg,tmp2,LANG_MB_FAVORITES,MB_OK);
log(LOG_NOTICE,LD_APP,tmp2);
tor_free(tmp1);tor_free(tmp2);tor_free(tmp3);
}
}
开发者ID:madnessw,项目名称:thesnow,代码行数:53,代码来源:dlg_routerres.c
示例5: test_pick_bad_tor2web_rendezvous_node
/* Make sure we never pick an RP if Tor2webRendezvousPoints doesn't
* correspond to an actual node. */
static void
test_pick_bad_tor2web_rendezvous_node(void *arg)
{
or_options_t *options = get_options_mutable();
const node_t *chosen_rp = NULL;
router_crn_flags_t flags = CRN_NEED_DESC;
int retval, i;
const char *tor2web_rendezvous_str = "dummy";
(void) arg;
/* Setup fake routerlist. */
helper_setup_fake_routerlist();
/* Parse Tor2webRendezvousPoints as a routerset. */
options->Tor2webRendezvousPoints = routerset_new();
retval = routerset_parse(options->Tor2webRendezvousPoints,
tor2web_rendezvous_str,
"test_tor2web_rp");
tt_int_op(retval, OP_GE, 0);
/* Pick rendezvous point. Since Tor2webRendezvousPoints was set to a
dummy value, we shouldn't find any eligible RPs. */
for (i = 0; i < 50 ; i++) {
chosen_rp = pick_tor2web_rendezvous_node(flags, options);
tt_ptr_op(chosen_rp, OP_EQ, NULL);
}
done:
routerset_free(options->Tor2webRendezvousPoints);
}
开发者ID:ageis,项目名称:tor,代码行数:33,代码来源:test_hs.c
示例6: NS
static void
NS(test_main)(void *arg)
{
routerset_t *set = routerset_new();
(void)arg;
NS_MOCK(geoip_is_loaded);
NS_MOCK(geoip_get_n_countries);
NS_MOCK(geoip_get_country);
routerset_refresh_countries(set);
tt_ptr_op(set->countries, OP_NE, NULL);
tt_int_op(set->n_countries, OP_EQ, 1);
tt_int_op((unsigned int)(*set->countries), OP_EQ, 0);
tt_int_op(CALLED(geoip_is_loaded), OP_EQ, 1);
tt_int_op(CALLED(geoip_get_n_countries), OP_EQ, 1);
tt_int_op(CALLED(geoip_get_country), OP_EQ, 0);
done:
NS_UNMOCK(geoip_is_loaded);
NS_UNMOCK(geoip_get_n_countries);
NS_UNMOCK(geoip_get_country);
routerset_free(set);
}
开发者ID:Archer-sys,项目名称:tor,代码行数:25,代码来源:test_routerset.c
示例7: test_pick_tor2web_rendezvous_node
/* Make sure we always pick the right RP, given a well formatted
* Tor2webRendezvousPoints value. */
static void
test_pick_tor2web_rendezvous_node(void *arg)
{
or_options_t *options = get_options_mutable();
const node_t *chosen_rp = NULL;
router_crn_flags_t flags = CRN_NEED_DESC;
int retval, i;
const char *tor2web_rendezvous_str = "test003r";
(void) arg;
/* Setup fake routerlist. */
helper_setup_fake_routerlist();
/* Parse Tor2webRendezvousPoints as a routerset. */
options->Tor2webRendezvousPoints = routerset_new();
retval = routerset_parse(options->Tor2webRendezvousPoints,
tor2web_rendezvous_str,
"test_tor2web_rp");
tt_int_op(retval, OP_GE, 0);
/* Pick rendezvous point. Make sure the correct one is
picked. Repeat many times to make sure it works properly. */
for (i = 0; i < 50 ; i++) {
chosen_rp = pick_tor2web_rendezvous_node(flags, options);
tt_assert(chosen_rp);
tt_str_op(chosen_rp->ri->nickname, OP_EQ, tor2web_rendezvous_str);
}
done:
routerset_free(options->Tor2webRendezvousPoints);
}
开发者ID:ageis,项目名称:tor,代码行数:34,代码来源:test_hs.c
示例8: test_conn_edge_ap_handshake_rewrite_and_attach_closes_conn_to_port0
static void
test_conn_edge_ap_handshake_rewrite_and_attach_closes_conn_to_port0(void *data)
{
entry_connection_t *conn = entry_connection_new(CONN_TYPE_AP, AF_INET);
addressmap_init();
origin_circuit_t *circuit = NULL;
crypt_path_t *path = NULL;
(void) data;
MOCK(get_options, get_options_mock);
MOCK(connection_ap_handshake_rewrite, connection_ap_handshake_rewrite_mock);
MOCK(connection_mark_unattached_ap_, connection_mark_unattached_ap_mock);
MOCK(node_get_by_nickname, node_get_by_nickname_mock);
init_rewrite_mock();
init_mock_options();
init_exit_node_mock();
rewrite_mock->should_close = 0;
rewrite_mock->exit_source = ADDRMAPSRC_NONE;
SET_SOCKS_ADDRESS(conn->socks_request, "http://www.wellformed.exit");
conn->socks_request->command = SOCKS_COMMAND_CONNECT;
options_mock->AllowDotExit = 1;
options_mock->ExcludeExitNodes = routerset_new();
options_mock->ExcludeExitNodesUnion_ = routerset_new();
options_mock->SafeLogging_ = SAFELOG_SCRUB_NONE;
int prev_log = setup_capture_of_logs(LOG_INFO);
int res = connection_ap_handshake_rewrite_and_attach(conn, circuit, path);
tt_int_op(unattachment_reason_spy, OP_EQ, END_STREAM_REASON_TORPROTOCOL);
tt_int_op(res, OP_EQ, -1);
tt_str_op(mock_saved_log_at(-1), OP_EQ, "Excluded relay in exit address 'http://www.exit'. Refusing.\n");
done:
UNMOCK(get_options);
UNMOCK(connection_ap_handshake_rewrite);
UNMOCK(connection_mark_unattached_ap_);
UNMOCK(node_get_by_nickname);
destroy_mock_options();
destroy_rewrite_mock();
destroy_exit_node_mock();
tor_free(circuit);
tor_free(path);
teardown_capture_of_logs(prev_log);
}
开发者ID:twstrike,项目名称:tor,代码行数:47,代码来源:test_connection_edge_ap_handshake.c
注:本文中的routerset_new函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论