examples: add simple-pipe #20

Closed
cblgh wants to merge 0 commits from example-simple-pipe into main
Collaborator

adds a simple example on the way to having something as fully featured as n0's unfortunately named dumbpipe

currently you can use this to e.g. pipe text files across an iroh connection. where i want to get is something like this but which also works with tcp streams and does so in a very svelte way (not having to reimplement too much of net.Conn/Addr and everything related to that). not sure how far i'll get on that but i want to see :)

as for source code origin declarations: #neverslop

adds a simple example on the way to having something as fully featured as n0's unfortunately named [ `dumbpipe`](https://www.dumbpipe.dev/) currently you can use this to e.g. pipe text files across an iroh connection. where i want to get is something like this but which also works with tcp streams and does so in a very svelte way (not having to reimplement too much of net.Conn/Addr and everything related to that). not sure how far i'll get on that but i want to see :) as for source code origin declarations: #neverslop
cblgh force-pushed example-simple-pipe from dbb27dfeed to 854789084c 2026-10-18 11:37:40 +00:00 Compare
Author
Collaborator

also kinda progresses #14 in that the SimplePipe type sketches a vague outline of the diff between iroh.SendStream / iroh.RecvStream and go's Reader/Writer interfaces

also kinda progresses #14 in that the SimplePipe type sketches a vague outline of the diff between iroh.SendStream / iroh.RecvStream and go's Reader/Writer interfaces
cblgh force-pushed example-simple-pipe from 854789084c to bd83d74e6c 2026-10-18 11:41:01 +00:00 Compare
cblgh added 1 commit 2026-10-18 11:42:00 +00:00
examples: add simple-pipe
continuous-integration/drone/push Build is passing
d4d0a3229f
cblgh force-pushed example-simple-pipe from bd83d74e6c to d4d0a3229f 2026-10-18 11:42:00 +00:00 Compare
cblgh marked the pull request as work in progress 2026-10-18 12:52:52 +00:00
Author
Collaborator

marked as wip bc i'd like to figure out how to neatly close on the receiver side. like, what's required from the sender? it could also be a matter of improving my very barebones implementation of the Reader/Writer interfaces so that they function w/ errors as intended

marked as wip bc i'd like to figure out how to neatly close on the receiver side. like, what's required from the sender? it could also be a matter of improving my very barebones implementation of the Reader/Writer interfaces so that they function w/ errors as intended
cblgh marked the pull request as ready for review 2026-10-18 13:07:52 +00:00
Author
Collaborator

aight i think as of d2fbde7c3b it does enough now (sends EOF if current data read == 0 && we have previously read data)

aight i think as of https://git.coopcloud.tech/decentral1se/iroh-go/commit/d2fbde7c3bc39e5bc2688f3ecd82bb58a512762a it does enough now (sends EOF if current data read == 0 && we have previously read data)
Author
Collaborator

re my tcp ambitions, this could maybe be a good starting point for launching investigations

(sorry for any & all thinking-out-loud comments that end up in yer email inbox d1!!)

2hrs later edit:

another reference, this time for i2p + tor support. this feels to me like it is going in a more complex direction though. not sure if it is needed or something simpler could do the job

onramp's tor parts might be easier to digest:

after looking at tor/listen.go i think the gist of this approach is to implement the net.Listener interface. the easy way to do it is to have a struct field that is a literal net.Listener instance -- listen.go's is OnionService.LocalListener -- gotten by calling net.Listen() to which we can punt most of the implementing of net.Listener's interface methods


next day edit:

here's the newer version of onramp but probably a lot more complex to look at for first steps than the earlier version

another day's edit:

re my tcp ambitions, this could maybe be a good starting point for launching investigations * https://github.com/KatelynHaworth/go-tproxy/tree/master * https://github.com/KatelynHaworth/go-tproxy/blob/master/example/tproxy_example.go (sorry for any & all thinking-out-loud comments that end up in yer email inbox d1!!) 2hrs later edit: another reference, this time for i2p + tor support. this feels to me like it is going in a more complex direction though. not sure if it is needed or something simpler could do the job * https://github.com/eyedeekay/onramp#usage * https://github.com/eyedeekay/onramp/blob/main/garlic.go 🧄 * https://github.com/eyedeekay/onramp/blob/main/EXAMPLE.md#usage-as-instance-of-a-struct-listener <-- this demonstrates exactly what i want to achieve tho! :) * https://github.com/cblgh/cerca/blob/main/server/server.go#L1034 this approach is compatible with how cerca's server is defined (and was actually made so by the author of onramp/garlic.go!) onramp's tor parts might be easier to digest: * https://github.com/eyedeekay/onramp/blob/main/onion.go * https://github.com/cretz/bine/tree/master/tor * https://github.com/cretz/bine/blob/master/tor/listen.go (server - serve tcp connection) * https://github.com/cretz/bine/blob/master/tor/dialer.go (client - open tcp connection) after looking at `tor/listen.go` i think the gist of this approach is to implement the `net.Listener` interface. the easy way to do it is to have a struct field that is a literal net.Listener instance -- listen.go's is `OnionService.LocalListener` -- gotten by calling `net.Listen()` to which we can punt most of the implementing of `net.Listener`'s interface methods --- next day edit: here's the newer version of `onramp` but probably a lot more complex to look at for first steps than the earlier version * https://github.com/go-i2p/onramp another day's edit: * here's a good example on actually implementing a dialer [go-i2p/sam3/stream.go](https://github.com/go-i2p/sam3/blob/883c757e71f86a102c6ac909411a26eb0c23976f/stream.go#L240) * barebones net.Conn implementation [go-i2p/sam3/SAMConn.go](https://github.com/go-i2p/sam3/blob/883c757e71f86a102c6ac909411a26eb0c23976f/SAMConn.go#L10-L66) * barebones net.Conn impl above actually just relies on return value from `net.Dial` [go-i2p/sam3/sam3.go](https://github.com/go-i2p/sam3/blob/883c757e71f86a102c6ac909411a26eb0c23976f/sam3.go#L76)
cblgh added 1 commit 2026-10-19 07:03:36 +00:00
simple-pipe: improve impl of Read
continuous-integration/drone/push Build is passing
db430e2dff
cblgh force-pushed example-simple-pipe from d2fbde7c3b to db430e2dff 2026-10-19 07:03:36 +00:00 Compare
Owner

@cblgh loving this, please do continue 🍿🍿🍿

I noticed that if you don't pass -v -secret ... on the receiver side, it just hangs. Also, if you miss the binary in the .gitignore, it always ends up wanting to be checked in with Git. I've tested this with success locally and remotely. Really Cool ™️

Will keep reading along and am very curious about the final API surface 🙏

@cblgh loving this, please do continue 🍿🍿🍿 I noticed that if you don't pass `-v -secret ...` on the receiver side, it just hangs. Also, if you miss the binary in the `.gitignore`, it always ends up wanting to be checked in with Git. I've tested this with success locally and remotely. Really Cool ™️ Will keep reading along and am very curious about the final API surface 🙏
cblgh added 2 commits 2026-10-19 09:26:32 +00:00
Author
Collaborator

@decentral1se yo ty for the testing! yeah it hangs but only because the endpoint is randomly generated to be something you don't know about XD latest commit addresses that by always dumping the '-endpoint xxx` line to stderr, which shouldn't cause any issues with redirecting the output to e.g. another file

ty for the .gitignore prod, i'm notoriously bad at including binaries there lol; cerca has a couple of binaries lurking in its git history that are unnecessarily inflating its size because of this tendency hehe


i've got some shit brewin with the tcp brainstorming from above btw but am having some issues with the last mile. rn a bit confused how to prototype the dialing of the incoming tcp connection (currently curl via dumbpipe) so that my iroh+tcp listener process doesn't hang forever waiting for a tcp connection that seemingly is never made

@decentral1se yo ty for the testing! yeah it hangs but only because the endpoint is randomly generated to be something you don't know about XD latest commit addresses that by always dumping the '-endpoint xxx` line to stderr, which shouldn't cause any issues with redirecting the output to e.g. another file ty for the .gitignore prod, i'm notoriously bad at including binaries there lol; cerca has a couple of binaries lurking in its git history that are unnecessarily inflating its size because of this tendency hehe --- i've got some shit brewin with the tcp brainstorming from above btw but am having some issues with the last mile. rn a bit confused how to prototype the dialing of the incoming tcp connection (currently curl via dumbpipe) so that my iroh+tcp listener process doesn't hang forever waiting for a tcp connection that seemingly is never made
Author
Collaborator

woop woop, my very simple echo serve over iroh is working :)

note to self: don't just hand-wave the Writer/Reader implementation haha :') i think it was getting stuck there a few times and through various small tweaks and absolutely chaotic hardcoding i managed to understand enough of the problem to get this to work. i think a more robust solution would probably look slightly different, especially if there's a 'native dialer' in go for these bits. but dang it works :)!

woop woop, my very simple echo serve over iroh is working :) note to self: don't just hand-wave the Writer/Reader implementation haha :') i think it was getting stuck there a few times and through various small tweaks and absolutely chaotic hardcoding i managed to understand enough of the problem to get this to work. i think a more robust solution would probably look slightly different, especially if there's a 'native dialer' in go for these bits. but dang it works :)!
cblgh added 1 commit 2026-10-19 14:10:32 +00:00
examples(simple-pipe): improve reader/writer implementation
continuous-integration/drone/push Build is passing
60fed571c6
decentral1se left a comment
Owner

🥇

🥇
Owner

Resolved a merge conflict & merged to main: 3b7f953540

Resolved a merge conflict & merged to main: https://git.coopcloud.tech/decentral1se/iroh-go/commit/3b7f953540f364dfb433c5c14e4f6fd3409b1440
decentral1se closed this pull request 2026-10-19 15:21:56 +00:00

Pull request closed

This pull request cannot be reopened because the branch was deleted.
Sign in to join this conversation.
No Reviewers
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: decentral1se/iroh-go#20