📄 readme
字号:
T2hproxyThis is a TFTP to HTTP proxy. To the TFTP client it looks like a TFTPserver. To the HTTP server it looks like a HTTP client. So you can storeyour boot files on the HTTP server. Or even create them with a CGIprogram. E.g. if you can get dhcpd to send a filename which has stringsrepresenting attributes of the client, as determined from the DHCPrequest, then you can get the CGI program to parse this and send theappropriate image, which might even be synthesised.There are two versions of the proxy, in Perl and in Java.1. The Perl version.This is the original quick Perl hack conceived in a moment of madness.:-) Perl is great for prototyping.To run it, you need Perl 5.8.0 or later and all the Perl modules listedat the top of the program installed. Edit and install the xinetd configfile as /etc/xinetd.d/t2hproxy and restart xinetd. The prefix is thestring that is prepended to all filenames to form the URL requested fromthe HTTP server. Remember you need the trailing / if the filenames don'tstart with /.This is only a proof-of concept. It has these drawbacks at the moment:+ (I don't consider this a draback, but some may.) It's started fromxinetd because xinetd handles all the socket listening, IP addresschecking, rate limiting, etc.+ It has no cache. Use a proxy to do the caching (there's a --proxyoption). This also takes care of fetching from outside a firewall.+ It reads the entire HTTP content into memory before serving. Ideallyit should stream it from the HTTP server to minimise memory usage. Thisis a serious drawback for booting lots of clients. Each instance of theserver will consume an amount of memory equal to the size of imageloaded.+ If the HTTP server is at the end of a slow link there is a delaybefore the first data block is sent. The client may timeout beforethen. Another reason for streaming, as this allows the first block tobe sent sooner. A local cache primed with the images in advance mayhelp. Using the blocksize option helps here because this causes theserver to send the OACK to the client immediately before the data isfetched and this prevents it from starting up another connection.+ The transfer size may not be obtainable from the HTTP headers in allcases, e.g. a CGI constructed image. This matters for clients that needthe tsize extension, which is not supported at the moment.If I'm feeling masochistic I may write a Java version, which should takecare of the multi-threading and streaming.2. The Java versionThe main problem with the Perl version is that it does not stream theHTTP input but sucks it all in at once. As mentioned, this causes adelay as well as requiring memory to hold the image. I could fix this bydoing the polling on the HTTP socket myself instead of letting LWP doit, but that's for later. Java has streaming facilities as well asthreading and is also somewhat portable. So I decided to be masochisticand give it a go. But boy is Java bureaucratic.You will need a Java 1.4 JRE, because I use the java.nio classes; andthe commons-httpclient and commons-logging jars from thejakarta.apache.org project. As I understand it, there are several waysto get those jars on your classpath. One is to put it in the directorywhere your java extensions jars are kept, normally$JAVA_HOME/jre/lib/ext. But it may not be writable to you. Another is toset your $CLASSPATH variable to have those jars in the path. A third isto use the -cp option of the java interpreter, see the shell scriptrunT2hproxy for details.All the source is in one Java file. build.xml is a "Makefile" for ant tocompile and jar it. You should then edit runT2proxy.sh as required, thenstart it. As with the Perl version, the prefix is what's prepended tothe filenames requested by the TFTP client, and the proxy is thehost:port string for the proxy if you are using one. On *ix you willneed root permission to listen on ports below 1024 (TFTP is at 69 UDP bydefault).Currently it logs to stderr, but you can change this by downloading andinstalling the log4j jar from jakarta.apache.org and instructingcommons-logging to use that, with a command line property setting and aproperty file. Destinations could be syslog, or a file, or an eventlogger, or...; it's supposedly very flexible.3. LicensingAll this code is GPLed. For details read the file COPYING found in theEtherboot top directory since it currently bundled with Etherboot. Idon't see the point of including COPYING in every directory.Ken Yap, October 2003
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -