-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for Titan protocol #11
base: master
Are you sure you want to change the base?
Conversation
Thanks for adding this. Hopefully you can finish it up so it can be merged. I was considering trying to add this a year ago but never had the time. |
Hi, I'll try to write documentation soon :) |
Thanks. Hopefully @pitr will see this so he can merge it. If not, then maybe there is a way to use your fork directly in golang somehow? Or I could always download the code myself directly, I suppose. |
I assume the client certs work the same way with a titan route as they do with a gemini one, by just using the default gig client cert function ( Two other things that might be useful is to have the logger print whether the request was for gemini or titan (aka: which scheme). Lastly, what if you made AllowProxying a slice of strings of schemes that are allowed, or something along those lines? |
It looks like your implementation of |
One more thing to consider is some form of timeout (from start of upload, or timeout between received bytes) on upload. I'm not sure if this is already a thing yet. |
It can be done with g := gig.Default()
g.ReadTimeout = time.Second * 10 I added some basic documentation to README. |
f55bd19
to
9b0de94
Compare
Cool, thanks!! Btw, I switched to your titan branch for gemini://auragem.space, and looks like it is working well so far. Haven't had any significant problems yet. |
One more thing I wanted to make sure was that if the mime parameter was not provided, then the spec says to default to "text/gemini". |
To support Titan router must strip path parameters from last segment of the path in find method. Otherwise paths like /foo;size=1 won't match declared path /foo in router. Path segment parameters are described in RFC 3986, section 3.3.
You right, fixed. |
Hey. I implemented Titan support as middleware. It required few changes in core of gig:
titan://
requestFakeConn required some minor adjustments to make writing UT possible.
Usage
A basic example is provided in
examples/titan
. The middleware handles parsing Titan parameters (size, mime and token) and stores them in the Context. Additionally, thetitan
property is set in the context depending on whenever handled request is done via titan or Gemini scheme.gig.AllowProxying
must be enabled to receive Titan requests.Eye candy
Things to consider
NewFakeContext
needs new optional argument - a reader. I did not want to refactor all uses of this function in single PR, so I implemented a functional option pattern. If you want to, I can open separate PR to move tlsState argument to option.;.+$
regex from URL. Not sure if this is an issue, they are rarely used anyway. Go's url library does not support them.TODO
Closes: #8