惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Attack and Defense Labs
Attack and Defense Labs
The GitHub Blog
The GitHub Blog
C
Check Point Blog
博客园_首页
MongoDB | Blog
MongoDB | Blog
N
Netflix TechBlog - Medium
F
Full Disclosure
Microsoft Security Blog
Microsoft Security Blog
爱范儿
爱范儿
Recent Announcements
Recent Announcements
阮一峰的网络日志
阮一峰的网络日志
G
GRAHAM CLULEY
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
T
Threat Research - Cisco Blogs
C
Cybersecurity and Infrastructure Security Agency CISA
V
Vulnerabilities – Threatpost
K
Kaspersky official blog
博客园 - 司徒正美
S
Schneier on Security
T
The Exploit Database - CXSecurity.com
Project Zero
Project Zero
云风的 BLOG
云风的 BLOG
Cisco Talos Blog
Cisco Talos Blog
Know Your Adversary
Know Your Adversary
雷峰网
雷峰网
V
V2EX - 技术
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Spread Privacy
Spread Privacy
罗磊的独立博客
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
S
Security Affairs
SecWiki News
SecWiki News
Schneier on Security
Schneier on Security
O
OpenAI News
Jina AI
Jina AI
PCI Perspectives
PCI Perspectives
Cyberwarzone
Cyberwarzone
Y
Y Combinator Blog
Apple Machine Learning Research
Apple Machine Learning Research
B
Blog RSS Feed
I
InfoQ
D
Docker
P
Palo Alto Networks Blog
Recorded Future
Recorded Future
M
MIT News - Artificial intelligence
博客园 - Franky
B
Blog
Scott Helme
Scott Helme
博客园 - 叶小钗
D
DataBreaches.Net

博客园 - 无名-小卒

Asp.net中SqlServer模式Session的多站点共享会话状态 - 无名-小卒 - 博客园 使用aspnet_regsql.exe 创建ASPState数据库,用来保存session会话 TCP实现P2P通信、TCP穿越NAT的方法、TCP打洞 P2P之后是P4P NAT的完全分析及其UDP穿透的完全解决方案 SQL Server 跨服务器操作 电话呼叫转移的设置方法大全 C#开发终端式短信的原理和方法 在C#程序中实现插件架构 C#.net winform skin 皮肤大全devexpress,IrisSkin,DotNetSkin,SkinCrafter C和C++中的主要数据类型和字节大小 导出excel的另外一种方法 asp.net里导出excel表方法汇总 浅谈HOOK技术在VC编程中的应用 [Visual C++]美化VC界面(用户登录界面) - 无名-小卒 VC界面美化之按钮 - 无名-小卒 EXCEL技巧─利用函数获取工作表名 VC7转换到VC8的常见问题 - 无名-小卒 window.open打开新窗口
IFSBrowser:一个老外的p2p软件
无名-小卒 · 2010-11-02 · via 博客园 - 无名-小卒

原文地址:
http://www.codeproject.com/webservices/ifs.asp

第一次翻译,还只是翻译了部分文章。

作者最近好像还有更新。

这是一个p2p软件,全称Internet File System,网络文件系统。是基于WebService实现的。实现的功能是:可以把自己的文件注册到网络上,让大家共享。
全文205k,我实在没有勇气去翻译。捡几个重要的部分介绍一下。

1:结构:
  peer 一个使用端,可以发布自己的文件让其网络共享,也可以获取一个声明为发布的文件到本地。
  Server 静态单一(singleton)的服务端,设有WebService。
  WebService:这个软件就是靠它实现p2p的了。定义?自己查吧。

2:使用方法:
  注册--〉登陆--〉可以查看获取网络文件/发布自己的文件。

3:Server是把每个使用端声明为发布的文件的(基本信息+发布用户端机器信息)注册到DB里面。诸如 文件名,文件所在文件夹名,大小,发布者信息(ip,port),虚拟目录名(好像是ifs自己的目录)

4:防火墙和“推”“拉”。
  事先定义:请求需要下载文件f的一端叫做p1,这个文件的所有者叫p2,服务器叫s。  考虑这四种情况:
  a:p1和p2都不在防火墙里面。也就是说p1和p2时可以互相看见的。这时候,下载文件的流程是这样的:p1登陆到s,获取f的基本信息。p1可以从这个信息里面获取f的所有者p2的一些基本信息,如ip,端口号,是否在火墙里等。既然p2部在火墙里面,p1就可以直接向p2(知道了他的endponit,that is ip+port)发送一个pull的命令.pull,简单的翻译为“拉”。即p1从p2的机器上直接找到文件,下载。
  b:p1不在火墙里,p2在火墙里面。这时候,p1是无法找到p2的。如何实现下载呢?方法叫做“Push”,简单的翻译为“推”。因为p1不在火墙里面,所以p2时可以访问到p1的。操作流程是这样的:p1登陆s,获取f的所有者p2的信息,发现在火墙里面,于是乎,p1向s发出请求,附加一个Push文件的Task给p2,p2的一个线程获取这个Task和p1的endpoint,然后p2主动向p1发送文件f。当然了,p1在发送了Push的请求之后,就准备接受文件了。
  c:p1在火墙里,p2不在火墙里。很容易,和第一种情况一样。
  d:p1和p2都在火墙里。这就意味着p1和p2都是不可见的。这时候,该s出马了。p1首先会像s发出一个请求Task,p2接受,但是发现p1也在墙里,so,p2把文件upload到s上面的一个空间上,上传结束后,通知p1(当然是通过s中转这个消息了),p1开始到s上找到这个空间,开始下载文件。

第一次看这么长的c++代码。我在看源码的时候,看到的一些重要的东东。

1:__gc*:声明为回收类型
2:PushCommand,PullCommand:

for what?

3:public __value enum TaskType : unsigned char
PushFile = 1,    //
DownloadFile = 2, // unimplemented
UploadFile = 3 // ditto

4:S"Press ENTER to stop the server..."//to String type
5: class P2PConfig. use to manage the xml config file which log the very info for system. the file name is 'IFS.P2P.xml'
<?xml version="1.0" encoding="UTF-16"?>
<p2pconfig>
  <item key="PeerID">851966d6-35d0-4d08-b251-9641d3616b63</item>
  <item key="IpAddress">127.0.0.1</item>
  <item key="Port">12000</item>
  <item key="P2PFmkNamespace">InternetFileSystem.P2PFramework</item>
  <item key="ThreadSleepTime">100</item>
  <item key="ThreadJoinTime">1000</item>
  <!-- poll for tasks each 10 minutes -->
  <item key="TaskPollInterval">600000</item>
</p2pconfig>
6:class NetHelper.use to manage all the net transport task.include 'Connect' to a IPEndPoint,'Close','WriteLine' by BufferSize=1024,'Read/WriteArray', and so on.
7:works only if the remote peer is not behind firewall
8:PublishFile.there are several situation for PublishFile:'PublishFile','PublishFileHere'. use virtualFolderPath
9:properties of a peer
String __gc* id;
String __gc* login;
String __gc* password;
String __gc* alias;
String __gc* ipEndPoint;
System::Boolean behindFirewall;
10:use WebService.//a funny file 'IFSWebService.wsdl'
11:interface ICommandExecutor (PeerCommand __gc* command,NetHelper __gc* netHelper)
12:

like '3',what's meaning of 'Pull'and'Push','Peer'and'Library'?
        PeerPull = 0, // issued FROM a remote peer
PeerPush = 1, // ditto
LibraryPush = 2, // issued from the library
LibraryPull = 3, // ditto

Download = 4, // UNSUPPORTED in this version
Upload = 5, // ditto
13:properties of Server
int port;
ServerStatus status;
TcpListener __gc* listener;
Thread __gc*

p2pThread;
int threadSleepTime;
int threadJoinTime;
String __gc* namespaceName;
Thread __gc* taskThread;
// the "int" can handle about a month time
int taskPollInterval;
String __gc* peerID;
IFSWebService __gc* webService;
14:class ServerManager have 3 method:SendPushCommand,SendPullCommand,SendMessage.why  send the two commands?