并非胡言却是乱语


DOSBox, a x86 emulator with DOS

Posted in 网络收藏夹 by xiaolin on the 04月 6th, 2006

dosbox.jpg持续的工作导致压力无限增大,为了缓解一下情绪,决定玩一下游戏,可怜俺的本本的显卡实在弱不禁风,现在的那些游戏是几乎玩不了,于是特别的怀念起10几年前dos时代的那些经典游戏,当然,网络世界只要你能想到的,基本上都可以找到——dosbox就是这么一个让怀旧的人第一眼就能喜欢上的东东。

简单的说,DosBox是一款开源的Dos模拟器,可以在各种操作系统下模拟运行大部分dos软件(当然包括各类DOS游戏),并且声音和鼠标控制都是和真实的DOS环境一样。

dosbox的官方地址:http://dosbox.sourceforge.net

装上之后,接下来要做的工作就是把当年俺最爱的游戏一一下载下来。。。

迟到一天的雨

Posted in 这就是生活 by xiaolin on the 04月 6th, 2006

终于还是下雨了,尽管这本应下在清明那天的。

早上应邀前往中关村数据中心参观——这是传说中北京最奢侈的数据中心之一,传言是去年倒闭之后被电信通给买了过来,现在又重新对外招揽托管业务。出门的时候还没下雨,但已经感觉到一丝寒意——我对今天的气温明显估计不足,但实在懒得上楼加衣服了,打车到目的地之后发现已经开始下雨,只可惜没时间雨中漫步感受春天的气息,况且这雨下的也确实让人不爽——这是一场明显酝酿不足的雨,原本希望一场春雨过后北京糟糕的空气能得到一些净化,但是看来一切都将依旧,其实这样的时候来场暴雨可能是最合适的。

参观的过程略去不谈了,因为机房临时更改了规定,我们由于没有托管机器在里面,所以无法进到里面,只能隔着玻璃门看一下,很是扫兴。这个数据中心不大(跟亦庄那个比起来,这里几乎可以忽略不计,不过在市内这样的也算是不小的规模了),不过设施倒是很齐全,算的上是我见到过的最完善的机房之一了。据说机房的带宽很不错,是真正的互联互通,电信网通都有几个G的带宽连进来,可惜没有办法当场测试。还有一个给我深刻印象的是进入机房之前的那个闪着蓝光的走廊,很是诡异神秘,可能设计者的用意是为了突出科技色彩,不过我倒是更觉得这像是一个娱乐场所的入口。走廊里有各式各样的监控产品的展示,各类摄像头是应有尽有,原来这个机房还有一个身份,就是公安部门的安保运营中心(不知道具体是做什么的,只能从名字猜测了)。

 

实现搜索结果的关键词变色标注的程序

Posted in ASP by xiaolin on the 04月 5th, 2006

在搜索得到的文本中,从第一个关键词出现的前50个字开始显示,把关键词替换为红色,这比单纯的用replace得到的显示结果更人性化一些,因为用replace的话一旦关键词出现在文本的后面,就可能出现在结果页面显示的文本简要里不能出现关键词。虽然是很老的代码了,不过对于现在的搜索脚本的编写依然有参考作用。 (阅读全文…)

清明时节沙纷飞

Posted in 这就是生活 by xiaolin on the 04月 5th, 2006

许多年没有去扫墓了,似乎是从我上大学那年开始吧。记忆中以前每年老爸都要带着我们去扫墓的,虽然年少无知的我并不清楚那些墓葬里长眠的是谁,但我的心是虔诚的,我会帮着锄去墓碑前的野草,摆好祭品,祭拜一番。已故的亲人并不都是葬在一个地方,但基本上都是靠近水的,周围是一片的绿色,而且扫墓的时候是在梅雨季节,因此总是能让人的心感觉到那么一种淡淡的愁绪。正所谓清明时节雨纷飞,实在是恰如其分。

许多年后的今天,因为工作的关系,没有办法在清明的时候回到老家去扫墓了,北京的天气在这个季节也总是沙土纷飞,实在很难让人有心情去缅怀故人,因此也就更加的怀念以前的生活,只是不知道什么时候能再有机会和家人一起去扫墓,去让自己的心灵得到一次洗礼。

 

Active FTP vs. Passive FTP, a Definitive Explanation

Posted in 技术文摘 by xiaolin on the 04月 4th, 2006

Contents:

 
 

Introduction

One of the most commonly seen questions when dealing with firewalls and other Internet connectivity issues is the difference between active and passive FTP and how best to support either or both of them. Hopefully the following text will help to clear up some of the confusion over how to support FTP in a firewalled environment.

This may not be the definitive explanation, as the title claims, however, I’ve heard enough good feedback and seen this document linked in enough places to know that quite a few people have found it to be useful. I am always looking for ways to improve things though, and if you find something that is not quite clear or needs more explanation, please let me know! Recent additions to this document include the examples of both active and passive command line FTP sessions. These session examples should help make things a bit clearer. They also provide a nice picture into what goes on behind the scenes during an FTP session. Now, on to the information…
 

The Basics

FTP is a TCP based service exclusively. There is no UDP component to FTP. FTP is an unusual service in that it utilizes two ports, a ‘data’ port and a ‘command’ port (also known as the control port). Traditionally these are port 21 for the command port and port 20 for the data port. The confusion begins however, when we find that depending on the mode, the data port is not always on port 20.
 

Active FTP

In active mode FTP the client connects from a random unprivileged port (N > 1023) to the FTP server’s command port, port 21. Then, the client starts listening to port N+1 and sends the FTP command PORT N+1 to the FTP server. The server will then connect back to the client’s specified data port from its local data port, which is port 20.

From the server-side firewall’s standpoint, to support active mode FTP the following communication channels need to be opened:

  • FTP server’s port 21 from anywhere (Client initiates connection)
  • FTP server’s port 21 to ports > 1023 (Server responds to client’s control port)
  • FTP server’s port 20 to ports > 1023 (Server initiates data connection to client’s data port)
  • FTP server’s port 20 from ports > 1023 (Client sends ACKs to server’s data port)

 

When drawn out, the connection appears as follows:

In step 1, the client’s command port contacts the server’s command port and sends the command PORT 1027. The server then sends an ACK back to the client’s command port in step 2. In step 3 the server initiates a connection on its local data port to the data port the client specified earlier. Finally, the client sends an ACK back as shown in step 4.

 

The main problem with active mode FTP actually falls on the client side. The FTP client doesn’t make the actual connection to the data port of the server–it simply tells the server what port it is listening on and the server connects back to the specified port on the client. From the client side firewall this appears to be an outside system initiating a connection to an internal client–something that is usually blocked.
 

Active FTP Example

Below is an actual example of an active FTP session. The only things that have been changed are the server names, IP addresses, and user names. In this example an FTP session is initiated from testbox1.slacksite.com (192.168.150.80), a linux box running the standard FTP command line client, to testbox2.slacksite.com (192.168.150.90), a linux box running ProFTPd 1.2.2RC2. The debugging (-d) flag is used with the FTP client to show what is going on behind the scenes. Everything in red is the debugging output which shows the actual FTP commands being sent to the server and the responses generated from those commands. Normal server output is shown in black, and user input is in bold.

There are a few interesting things to consider about this dialog. Notice that when the PORT command is issued, it specifies a port on the client (192.168.150.80) system, rather than the server. We will see the opposite behavior when we use passive FTP. While we are on the subject, a quick note about the format of the PORT command. As you can see in the example below it is formatted as a series of six numbers separated by commas. The first four octets are the IP address while the last two octets comprise the port that will be used for the data connection. To find the actual port multiply the fifth octet by 256 and then add the sixth octet to the total. Thus in the example below the port number is ( (14*256) + 178), or 3762. A quick check with netstat should confirm this information.

testbox1: {/home/p-t/slacker/public_html} % ftp -d testbox2
Connected to testbox2.slacksite.com.
220 testbox2.slacksite.com FTP server ready.
Name (testbox2:slacker): slacker
—> USER slacker
331 Password required for slacker.
Password: TmpPass
—> PASS XXXX
230 User slacker logged in.
—> SYST
215 UNIX Type: L8

Remote system type is UNIX.
Using binary mode to transfer files.
ftp> ls
ftp: setsockopt (ignored): Permission denied
—> PORT 192,168,150,80,14,178

200 PORT command successful.
—> LIST
150 Opening ASCII mode data connection for file list.
drwx—— 3 slacker users 104 Jul 27 01:45 public_html
226 Transfer complete.
ftp> quit
—> QUIT
221 Goodbye.

 

Passive FTP

In order to resolve the issue of the server initiating the connection to the client a different method for FTP connections was developed. This was known as passive mode, or PASV, after the command used by the client to tell the server it is in passive mode.

In passive mode FTP the client initiates both connections to the server, solving the problem of firewalls filtering the incoming data port connection to the client from the server. When opening an FTP connection, the client opens two random unprivileged ports locally (N > 1023 and N+1). The first port contacts the server on port 21, but instead of then issuing a PORT command and allowing the server to connect back to its data port, the client will issue the PASV command. The result of this is that the server then opens a random unprivileged port (P > 1023) and sends the PORT P command back to the client. The client then initiates the connection from port N+1 to port P on the server to transfer data.

From the server-side firewall’s standpoint, to support passive mode FTP the following communication channels need to be opened:

  • FTP server’s port 21 from anywhere (Client initiates connection)
  • FTP server’s port 21 to ports > 1023 (Server responds to client’s control port)
  • FTP server’s ports > 1023 from anywhere (Client initiates data connection to random port specified by server)
  • FTP server’s ports > 1023 to remote ports > 1023 (Server sends ACKs (and data) to client’s data port)

 

When drawn, a passive mode FTP connection looks like this:

In step 1, the client contacts the server on the command port and issues the PASV command. The server then replies in step 2 with PORT 2024, telling the client which port it is listening to for the data connection. In step 3 the client then initiates the data connection from its data port to the specified server data port. Finally, the server sends back an ACK in step 4 to the client’s data port.

 

While passive mode FTP solves many of the problems from the client side, it opens up a whole range of problems on the server side. The biggest issue is the need to allow any remote connection to high numbered ports on the server. Fortunately, many FTP daemons, including the popular WU-FTPD allow the administrator to specify a range of ports which the FTP server will use. See Appendix 1 for more information.

The second issue involves supporting and troubleshooting clients which do (or do not) support passive mode. As an example, the command line FTP utility provided with Solaris does not support passive mode, necessitating a third-party FTP client, such as ncftp.

With the massive popularity of the World Wide Web, many people prefer to use their web browser as an FTP client. Most browsers only support passive mode when accessing ftp:// URLs. This can either be good or bad depending on what the servers and firewalls are configured to support.
 

Passive FTP Example

Below is an actual example of a passive FTP session. The only things that have been changed are the server names, IP addresses, and user names. In this example an FTP session is initiated from testbox1.slacksite.com (192.168.150.80), a linux box running the standard FTP command line client, to testbox2.slacksite.com (192.168.150.90), a linux box running ProFTPd 1.2.2RC2. The debugging (-d) flag is used with the FTP client to show what is going on behind the scenes. Everything in red is the debugging output which shows the actual FTP commands being sent to the server and the responses generated from those commands. Normal server output is shown in black, and user input is in bold.

Notice the difference in the PORT command in this example as opposed to the active FTP example. Here, we see a port being opened on the server (192.168.150.90) system, rather than the client. See the discussion about the format of the PORT command above, in the Active FTP Example section.

testbox1: {/home/p-t/slacker/public_html} % ftp -d testbox2
Connected to testbox2.slacksite.com.
220 testbox2.slacksite.com FTP server ready.
Name (testbox2:slacker): slacker
—> USER slacker
331 Password required for slacker.
Password: TmpPass
—> PASS XXXX
230 User slacker logged in.
—> SYST
215 UNIX Type: L8

Remote system type is UNIX.
Using binary mode to transfer files.
ftp> passive
Passive mode on.
ftp> ls
ftp: setsockopt (ignored): Permission denied
—> PASV

227 Entering Passive Mode (192,168,150,90,195,149).
—> LIST
150 Opening ASCII mode data connection for file list
drwx—— 3 slacker users 104 Jul 27 01:45 public_html
226 Transfer complete.
ftp> quit —> QUIT
221 Goodbye.

 

Other Notes

A reader, Maarten Sjouw, pointed out that active FTP will not function when used in conjunction with a client-side NAT (Network Address Translation) device which is not smart enough to alter the IP address info in FTP packets.
 

Summary

The following chart should help admins remember how each FTP mode works:

Active FTP :
command : client >1023 -> server 21
data : client >1023 < - server 20

Passive FTP :
command : client >1023 -> server 21
data : client >1023 -> server >1023

 

A quick summary of the pros and cons of active vs. passive FTP is also in order:

Active FTP is beneficial to the FTP server admin, but detrimental to the client side admin. The FTP server attempts to make connections to random high ports on the client, which would almost certainly be blocked by a firewall on the client side. Passive FTP is beneficial to the client, but detrimental to the FTP server admin. The client will make both connections to the server, but one of them will be to a random high port, which would almost certainly be blocked by a firewall on the server side.

Luckily, there is somewhat of a compromise. Since admins running FTP servers will need to make their servers accessible to the greatest number of clients, they will almost certainly need to support passive FTP. The exposure of high level ports on the server can be minimized by specifying a limited port range for the FTP server to use. Thus, everything except for this range of ports can be firewalled on the server side. While this doesn’t eliminate all risk to the server, it decreases it tremendously. See Appendix 1 for more information.

References

An excellent reference on how various internet protocols work and the issues involved in firewalling them can be found in the O’Reilly and Associates book, Building Internet Firewalls, 2nd Ed, by Brent Chapman and Elizabeth Zwicky.

Finally, the definitive reference on FTP would be RFC 959, which sets forth the official specifications of the FTP protocol. RFCs can be downloaded from numerous locations, including http://www.faqs.org/rfcs/rfc959.html.

from:http://slacksite.com/other/ftp.html

今天的奥运森林公园

Posted in 影像志 by xiaolin on the 04月 4th, 2006

PICT0217这几天的空气质量不大好,天灰蒙蒙的,所以拍摄的效果不是很好。

中午阳光渐强,能见度稍微有所提高,赶紧拍了几张。

绿色正在逐渐的蔓延,但愿这些小树都能茁壮成长。 

 

点击图片可以查看完整的相册。

在线favicon.ico生成器

Posted in 网络收藏夹 by xiaolin on the 04月 3rd, 2006

favicon.jpghttp://www.html-kit.com/favicon/

很方便的生成favicon.ico(本站的icon就是在那生成的)

使用方法:现在本机制作一个16×16或32×32的jpg图片,然后上传,就可以生成一个16*16的icon了,同时还会生成一个上下翻屏的gif图片,还可以填入滚动的文字,这样就会生成带有那些文字和你的icon的跑马灯效果的gif图片了。

不要以为你的世界听不到他们的声音,其实那是因为他们爱的深沉

Posted in 星园夜话 by xiaolin on the 04月 2nd, 2006

写下这些给弟弟看的文字之前,我有一段很长时间的思考,这段时间甚至长达60天——这2个月以来我一直在想以什么样的方式来把这个事情妥善的解决,起码是妥善的表达出我的观点。愚人节刚刚过去,本来应该在几个小时以前就开始写的,但是我不想把这么严肃的一件事情放在这么一个本该娱乐的日子里,所以现在我想我可以很坦诚的来说一些话了,这是作为哥哥的我必须要尽到的一份责任。 (阅读全文…)

春来花满枝

Posted in 星园夜话 by xiaolin on the 04月 1st, 2006

PICT0020.jpg经过长期苦口婆心的忽悠,老婆终于答应给我买一个长焦的相机,只可惜预算实在有限,加之我本人对摄影似懂非懂,所以那些单反的是早早就被排除在外,经过在网上的收集资料,初步圈定了几款12倍光学变焦的机器,并最终以较低的价格购得绝版的柯美Z6水货一台(当然得感谢美女minmin,哈哈,多亏她介绍了个卖DC的朋友给我)。虽然今天是愚人节,不过我们倒是挺顺利的,这篇帖子虽然赶在愚人节快要结束的时候才发,不过基本上是和愚人无关,只有春意满园。

我家的小区现在终于回归了原本的水榭花都的本色,今天拿着新相机回家的路上忍不住就先照了几张。 (阅读全文…)

« 上一页