Golang zcat example

I am working through this example to understand how the dialing works

I use the following command to run… which dials the service

go run main.go golanghttp

[ 0.000] INFO sdk-golang/ziti/edge/api.(*lazyClient).ensureConfigPresent: loading Ziti configuration from /Users/houst/.zssh/zssh.json
[ 0.181] INFO main.runFunc: connected

However… it then hangs… and when I press enter… I receive the following error

HTTP/1.1 400 Bad Request
Content-Type: text/plain; charset=utf-8
Connection: close

I may be doing something wrong the service… as I dont really understand what this example does.

Any tips?

zcat is a ‘zitified’ netcat. You are clearly attempting to use zcat to connect to an HTTP server. you can definitely do that - but you need to know how to enter a proper HTTP GET payload to receive an HTTP 200 (successful) response… Which makes me wonder if you should do that (I say - no, not worth it :slight_smile: )

But if you want… You can…

  • research netcat
  • try runing netcat WITHOUT ziti… Just on the local network. Start one in ‘listen’ mode, and attach a client and see what it does
  • now try running regular netcat OVER ziti (which isn’t a lot different but just showing how to progress to understand)
  • try run netcat in listen mode and use zcat as the client. since zcat is a ‘zitified’ netcat, it’ll work just fine
  • now get your hip-waders on and go read the HTTP spec and what is expected of an HTTP client/server interaction (including the fact that an HTTP request is terminated by CRLF (see the spec) I don’t think it’s worth your time, but hey, maybe it’s interesting to you??? :slight_smile: after you do that you’ll better understand what I meant when I said “you need to know how to enter a proper HTTP GET payload to receive an HTTP 200” above…

That’s gonna be a lot to learn/understand in my opinion. At the end of the day - zcat is really just not meant to attach to an HTTP server. Sure it works if you know what you’re doing (which is also true when trying to use netcat to attach to http) but it involves a fair bit of HTTP protocol understanding which might not be worth your time?

1 Like

Cool… thanks for the details…

So… it would work better if I had a service attached to a non http server.

Hmm… this seems a really stupid question… but how do you do that?

Any tips to point me in the right direction?

Remember, part of OpenZiti’s power is it’s flexibility. It’s not “just” an HTTP proxy. It’s a secure, zero trust tunnel from point a to point b. You can run any service on the other side. And yes, I would recommend you NOT use http as your target service.

I laid out the steps to get there in the last post.

  • learn netcat (or nc). using nothing but your local machine:
    • start a netcat server/listener
    • attach a netcat client, echo some bytes…
  • once you know how to do that - just make a service that exposes your netcat ‘server’ to some netcat ‘client’ but do it over ziti. Then you can move your client ‘anywhere else’ in the world. Basically change your ‘host.v1’ config from pointing at your web server to pointing to your listening netcat server/listener…

I know I’ve recorded this video before - I’ll see if I can dig it up (no promises :slight_smile: ). That the basic steps…

1 Like

ahh… I get it now… you have to use it to create a listener… and then point the service to that listener…

then… you can use the znetcat to call the netcat server… through the service its connected with…

I will give this a go…