An NNTP proxy in one screenful of Tcl

(Printer friendly version)

One reason Tcl is my favorite language is the ease with which you can write network applications.

Consider this little NNTP proxy. I want to be able to run a local news server (so I can read news offline) and a non-GUI newsreader on my PowerBook (to access comp.lang.tcl & other groups), but my current broadbrand provider has lousy news servers as compared to my longtime ISP (from whom, unfortunately, I cannot currently get DSL thanks to qworst).

I do have a friend, however, who lives only a mile away, who can get DSL. He's tenatively agreed to host this little proxy for me. That way I can connect to a good NNTP server without having my old credentials passing clear text over the Internet.

#!/usr/bin/tclsh

proc accept {sock host port} {
    if {[lsearch -exact {127.0.0.1} $host] == -1 ||
        [catch {socket -async news.example.com 119} conn]} then {
        catch {close $sock}
    } else {
        fconfigure $sock -blocking 0 -buffering line
        fconfigure $conn -blocking 0 -buffering line
        fileevent $sock readable [list copy-from-to $sock $conn]
        fileevent $conn readable [list copy-from-to $conn $sock]
    }
}

proc copy-from-to {source destination} {
    if {[eof $source] || [eof $destination] ||
        [catch {puts $destination [gets $source]}]} then {
        catch {close $source}
        catch {close $destination}
    }
}

socket -server accept 8119
vwait forever

Actually, that should work with any line oriented protocol, not just NNTP.

The bolded items above are things you'd want to customize to your environment. You'd probably want to flush out the list of IP addresses you want to allow to connect to something beyond just 127.0.0.1 (or remove the check all together if you wanted to proxy for the whole world). You'd change where you are proxying to from news.example.com port 119 and (maybe) change the port that the daemon binds to from 8119 to something else.

—Michael A. Cleverly

Comments

Michael A. Cleverly: [ mail | www | link ]

Roberto Mello spotted a bug in the code (which I've taken the liberty of fixing; this comment is to give credit where credit is due...)

<blush>When I retyped the code and html-ized it I accidentally left out the $host from the [lsearch] command.</blush>

Thu, 09 Jun 2005, 10:53

Re: [ mail | www | link ]
cctv distributors in mumbai | cctv camera manufacturers | panasonic cctv | wireless camera india | cctv | cctv online |

Sun, 23 Dec 2018, 12:06

ff fg dgf df: [ mail | www | link ]
housekeeping services in mumbai | housekeeping services in navimumbai | facility management companies in mumbai | housekeeping agency in mumbai | housekeeping contractors in mumbai | housekeeping services in thane | security guard services in mumbai | security services in mumbai | security agency in mumbai | security companies in mumbai | security guard in mumbai | security guard agency in mumbai |

Fri, 05 Apr 2019, 04:26

Ravi Kumar: [ mail | www | link ]
There is an internet hierarchy which is called as Domain Name System or DNS, which consists of many domains in a hierarchical order. This system begins with root level domain which is followed by top level domains and then second level domains and the last domain in this hierarchy is the subdomain. A subdomain is a part of a larger domain. In the whole Domain Name System hierarchy, the root domain is the only domain which is not the subdomain because, it is on the top and the hierarchy begins from this domain. Subdomain is an important term under the Domain Name System or DNS.

Sat, 06 Jul 2019, 09:46

Call Girls in Gurgaon: [ mail | www | link ]
Call Girls in Gurgaon
Call Girl Gurgaon
Call Girls Gurgaon
Call Girl in Gurgaon
Gurgaon Call Girls
Gurgaon Call Girl
Gurgaon Escort
Gurgaon Escorts
escort in Gurgaon
escorts in Gurgaon
escorts in Gurgaon
Call Girls in Dwarka
Call Girl Dwarka
Call Girls Dwarka
Call Girl in Dwarka
Dwarka Call Girls
Dwarka Call Girl
Dwarka Escort
Dwarka Escorts
escort in dwarka
escorts in dwarka
escorts in dwarka
Call Girls in Gurgaon
Call Girl Gurgaon
Call Girls Gurgaon
Call Girl in Gurgaon
Gurgaon Call Girls
Gurgaon Call Girl
Gurgaon Escort
Gurgaon Escorts
escort in Gurgaon
escorts in Gurgaon
escorts in Gurgaon
Call Girls in sikanderpur gurgaon
Call Girls in sohna road gurgaon
Call Girls in mg road gurgaon
Call Girls in iffco chowk gurgaon
Call Girls in Haridwar
Call Girls in sushant lok
Call Girls in Gurgaon
Call Girls in Dehradun
Call Girls in electronic city
Call Girls in Noida
call girls in mumbai
plumbing company Toronto
plumbing company Mississauga
quickbooks support phone number
plumbing company Toronto

Mon, 23 Dec 2019, 23:56

rb88: [ mail | www | link ]
Thank you for helping people get the information they need. Great stuff as usual. Keep up the great work! If you are looking for more information, you can use this site: rb88

Fri, 20 Mar 2020, 01:13

easyluxuryshop: [ mail | www | link ]
The Great Kanto Earthquake struck Japan in 1923,destroying the Seikosha factory and stocks and halting production of timepieces.However,the determined Hattori decided to quickly rebuild,despite the massive costs,and only one year later the world was introduced to the very first Swiss Replica Watch with the name%93Seiko%94on the dial.(%93Seiko%94is,of course,an abbreviation of%93Seikosha,%94which means,roughly,%93House of Exquisite Workmanship%94in Japanese.)The use of a non-English name indicated that Hattori had become confident enough in the quality of his products that they would sell despite the widely held belief(at the time)that products made in the West were of superior quality.The watch had a 24.2-mm case made of nickel and a 9-ligne,7-jewel%A0movement.Its small seconds subdial was standard all the way up until 1950,when the Seiko Super debuted as the first Japanese Hublot Replicas with a central seconds hand.

Tue, 09 Jun 2020, 01:50

Veronica: [ mail | www | link ]
Having email is a essential thing when you use internet, but to use email more effectively is not easy, Hotmail login account has the tutorial and tips you need.

Wed, 08 Jul 2020, 02:39

Deziner Guys: [ mail | www | link ]
I like what you guys are up too. Such smart work and reporting! Keep up the superb works guys I have incorporated you guys to my blogroll. I think it will improve the value of my website 메이저사이트 ========================================== Thanks for the one of the nicest blogs i have read in a while. 더킹카지노 추천

Thu, 10 Sep 2020, 07:42

alex: [ mail | www | link ]
It's a very useful blog. Thank you for getting a lot of information. 카지노사이트 파워볼사이트 토토사이트 안전놀이터 안전한놀이터 메이저사이트 비아그라구매

Thu, 17 Sep 2020, 03:04

magzinetoday: [ mail | www | link ]
Greetings Im itching to know if I may use this article in one of my blogs if I link back to you? Thanks Paket indihome

Sat, 07 Nov 2020, 06:40

3G: [ mail | www | link ]
You can certainly see your expertise within the paintings you write. The world hopes for even more passionate writers such as you who aren%92t afraid to say how they believe. All the time follow your heart. 먹튀검증 ================================================================================= I%92m impressed, I have to admit. Really rarely do you encounter a weblog that%92s both educative and entertaining, and let me tell you, you%92ve got hit the nail for the head. Your notion is outstanding; the problem is a thing that not enough consumers are speaking intelligently about. We are happy we found this within my seek out some thing about it. 토토사이트

Mon, 16 Nov 2020, 05:43

Gigi Smith: [ mail | www | link ]
I think I need more information hearing aids

Wed, 16 Dec 2020, 00:27

magzinetoday: [ mail | www | link ]
of course data entry services are very expensive that is why always make a backup of your files:: 더킹카지노 사이트 ================================================= I am not rattling good with English but I line up this rattling easygoing to translate. 메리트카지노

Sat, 02 Jan 2021, 00:03

p10: [ mail | www | link ]
Thanks for the several tips shared on this weblog. I have seen that many insurance carriers offer shoppers generous savings if they favor to insure a couple of cars together. A significant quantity of households have got several cars or trucks these days, particularly those with older teenage kids still living at home, as well as savings upon policies may soon begin. So it is good to look for a good deal. 먹튀검증 ================================================================================= Thank you for sharing this great write-up. Very inspiring! (as always, btw) 토토사이트

Sun, 03 Jan 2021, 05:22

Alisha bhabhi: [ mail | www | link ]
Hi, folks, I'm Naina Kaur from Jaipur Escorts Service folks. We give prominent escorts administrations. We have hot and provocative escort young ladies. they can do anything for you and your fulfillment actually and intellectually. what's more, on the off chance that you need this assistance, at that point you need to visit Female Escort Jaipur Female Escort in Jaipur Female Jaipur Escort Service Female Escort Service in Jaipur our site and experience the rundown of accessible young ladies. At the point when you are finished choosing you can visit her profile and make the booking. You can book her for certain hours or a whole end of the week relying upon your desire. Simply click on this connection.

Sat, 03 Apr 2021, 04:27

Alisha bhabhi: [ mail | www | link ]
Hello... I'm Sonia from Rajasthan escort administrations. We are giving a wide range of escort benefits all over Rajasthan. inside the least expensive cost. Call Girl Jaipur Call Girl in Jaipur Jaipur Call Girl Service Call Girl Service in Jaipur what's more, I reveal to you one thing likewise we are the best escort organization in all over Rajasthan. Also, on the off chance that you need so fun with the hot and provocative young ladies, at that point click on the connection.

Sat, 03 Apr 2021, 04:42

joker123: [ mail | www | link ]

Your writing style is marvellous and you have given a good book. Keep your work

Sun, 01 Aug 2021, 04:39

Buy Afghan Black Hash: [ mail | www | link ]

Just as before, you need to alteration your tax bill obligations for anybody who is expected an important substantial return.

Sun, 01 Aug 2021, 04:40

&#52852;&#51648;&#45432;&#49324;&#51060;&#53944;: [ mail | www | link ]
https://www.yert200.com - 카지노사이트 https://www.yert200.com/sands - 샌즈카지노 https://www.yert200.com/merit - 메리트카지노 https://www.yert200.com/first - 퍼스트카지노 카지노사이트 샌즈카지노 메리트카지노 퍼스트카지노

Mon, 06 Sep 2021, 00:32

online casino: [ mail | www | link ]
https://www.shine900.com - 카지노사이트 https://www.shine900.com/sands - 샌즈카지노 https://www.shine900.com/theking - 더킹카지노 https://www.shine900.com/first - 퍼스트카지노 https://www.shine900.com/33casino - 33카지노 https://www.shine900.com/gatsby - 개츠비카지노 https://www.shine900.com/merit - 메리트카지노 카지노사이트 샌즈카지노 더킹카지노 퍼스트카지노 33카지노 개츠비카지노 메리트카지노

Mon, 06 Sep 2021, 00:32

online baccarat: [ mail | www | link ]
https://www.gain777.com - 카지노사이트 https://www.gain777.com/sands - 샌즈카지노 https://www.gain777.com/theking - 더킹카지노 https://www.gain777.com/first - 퍼스트카지노 https://www.gain777.com/thezone - 더존카지노 https://www.gain777.com/yes - 예스카지노 https://www.gain777.com/super - 슈퍼카지노 https://www.gain777.com/world - 월드카지노 https://www.gain777.com/33 - 메리트카지노 https://www.gain777.com/gatsby - 개츠비카지노 카지노사이트 샌즈카지노 더킹카지노 퍼스트카지노 더존카지노 예스카지노 슈퍼카지노 월드카지노 메리트카지노 개츠비카지노

Mon, 06 Sep 2021, 00:32

online blackjack: [ mail | www | link ]
https://www.kkr789.com - 카지노사이트 https://www.kkr789.com/yes - 예스카지노 https://www.kkr789.com/gangnam - 강남카지노 https://www.kkr789.com/blank-1 - 샌즈카지노 https://www.kkr789.com/king - 더킹카지노 https://www.kkr789.com/first - 퍼스트카지노 https://www.kkr789.com/merit - 메리트카지노 카지노사이트 예스카지노 강남카지노 샌즈카지노 더킹카지노 퍼스트카지노 메리트카지노

Mon, 06 Sep 2021, 00:33

casino: [ mail | www | link ]
https://www.aace777.com - 카지노사이트 https://www.aace777.com/33casino - 33카지노 https://www.aace777.com/merit - 메리트카지노 https://www.aace777.com/gatsby - 개츠비카지노 https://www.aace777.com/super - 슈퍼카지노 https://www.aace777.com/mcasino - 퍼스트카지노 https://www.aace777.com/sands - 샌즈카지노 https://www.aace777.com/obama - 오바마카지노 https://www.aace777.com/trump - 룰렛사이트 https://www.aace777.com/live - 실시간카지노 https://www.aace777.com/bacarrat - 사설바카라 https://www.aace777.com/mgmcasino - MGM카지노 https://www.aace777.com/avata - 아바타카지노 카지노사이트 33카지노 메리트카지노 개츠비카지노 슈퍼카지노 샌즈카지노 오바마카지노 룰렛사이트 실시간카지노 사설바카라 퍼스트카지노 MGM카지노 아바타카지노

Mon, 06 Sep 2021, 00:33

casino: [ mail | www | link ]
https://www.qqueen700.com - 카지노사이트 https://www.qqueen700.com/sands - 샌즈카지노 https://www.qqueen700.com/thekingo - 더킹카지 https://www.qqueen700.com/merit - 메리트카지노 https://www.qqueen700.com/firstcasino11 - 퍼스트카지노 https://www.qqueen700.com/yescasino11 - 예스카지노 https://www.qqueen700.com/baccarat - 슈퍼카지노 https://www.qqueen700.com/live - 33카지노 https://www.qqueen700.com/obama - 개츠비카지노 카지노사이트 샌즈카지노 메리트카지노 라이브카지노 퍼스트카지노 예스카지노 슈퍼카지노 33카지노 개츠비카지노

Mon, 06 Sep 2021, 00:34

online casino: [ mail | www | link ]
https://www.rcasinosite.com - 카지노사이트 https://www.rcasinosite.com/meritcasino - 메리트카지노 https://www.rcasinosite.com/sandscasino - 샌즈카지노 https://www.rcasinosite.com/firstcasino - 퍼스트카지노 https://www.rcasinosite.com/thekingcasino - 더킹카지노 https://www.rcasinosite.com/yescasino - 예스카지노 https://www.rcasinosite.com/gatsbycasino - 개츠비카지노 https://www.rcasinosite.com/gatsbycasino - 슈퍼카지노 카지노사이트 메리트카지노 샌즈카지노 퍼스트카지노 더킹카지노 예스카지노 개츠비카지노 슈퍼카지노

Mon, 06 Sep 2021, 00:34

casino: [ mail | www | link ]
https://www.hgame789.com/ 카지노사이트 https://www.hotgame8.com/ 인터넷카지노 https://www.worisandscasino.com/ 샌즈카지노 https://www.kakeriun.com/ 메리트카지노 https://www.hgame56.com/ 카지노사이트 https://www.woca99.com/ 카지노사이트 https://www.hgg99.com/ 카지노사이트 https://www.hgame88.com/ 카지노사이트 https://www.hgame75.com/ 카지노사이트 인터넷카지노 카지노사이트 메리트카지노 퍼스트카지노 카지노사이트 카지노사이트 카지노사이트 카지노사이트 카지노사이트

Mon, 06 Sep 2021, 00:35

jhon set: [ mail | www | link ]
Within that period, the use of the lofts as residential spaces are known to be illegal since the buildings are not designated as residential property. Bricklaying

Wed, 06 Oct 2021, 13:24

Leave a comment

Name:  
Email: (optional)
URL: (optional)

Your comment: