Compare commits
6 Commits
Author | SHA1 | Date |
---|---|---|
nixo | db423191d9 | |
nixo | 5b5f989f6b | |
nixo | 8d62ce5f29 | |
nixo | d105d81f5c | |
nixo | 7a2e06129d | |
nixo | e0c52b3c86 |
10
Readme.org
10
Readme.org
|
@ -11,16 +11,16 @@ It's written in [[https://julialang.org/][Julia]].
|
||||||
The usage is quite simple and similar to [[https://github.com/JuliaWeb/HTTP.jl][HTTP.jl]]
|
The usage is quite simple and similar to [[https://github.com/JuliaWeb/HTTP.jl][HTTP.jl]]
|
||||||
|
|
||||||
First, import the library
|
First, import the library
|
||||||
#+begin_src julia
|
#+begin_src julia :tangle server.jl
|
||||||
using Gemenon
|
using Gemenon
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
Then, setup the SSL config
|
Then, setup the SSL config
|
||||||
#+begin_src julia
|
#+begin_src julia :tangle server.jl
|
||||||
const verify_callback(preverify_ok, x509_ctx)::Cint = 1
|
const verify_callback(preverify_ok, x509_ctx)::Cint = 1
|
||||||
|
|
||||||
function init_ssl_context()
|
function init_ssl_context()
|
||||||
ctx = Gemenon.OpenSSL.SSLContext()
|
ctx = Gemenon.OpenSSL.SSLContext(mode = Gemenon.OpenSSL.ServerMode)
|
||||||
Gemenon.OpenSSL.ca_chain!(ctx, "./cert.crt", "./key.key")
|
Gemenon.OpenSSL.ca_chain!(ctx, "./cert.crt", "./key.key")
|
||||||
|
|
||||||
Gemenon.OpenSSL.set_options!(ctx, Gemenon.OpenSSL.SSL_OP_NO_SSLv3)
|
Gemenon.OpenSSL.set_options!(ctx, Gemenon.OpenSSL.SSL_OP_NO_SSLv3)
|
||||||
|
@ -36,7 +36,7 @@ Then, setup the SSL config
|
||||||
You are ready to listen for connections!
|
You are ready to listen for connections!
|
||||||
You can do this like in Mux.jl
|
You can do this like in Mux.jl
|
||||||
|
|
||||||
#+begin_src julia
|
#+begin_src julia :tangle server.jl
|
||||||
@app test = (
|
@app test = (
|
||||||
req -> document(req.conn, """
|
req -> document(req.conn, """
|
||||||
# Welcome to Gemenon!
|
# Welcome to Gemenon!
|
||||||
|
@ -45,5 +45,5 @@ You can do this like in Mux.jl
|
||||||
=> gemini://nixo.xyz/ The Gemenon-Powered Anonymous Board
|
=> gemini://nixo.xyz/ The Gemenon-Powered Anonymous Board
|
||||||
"""))
|
"""))
|
||||||
|
|
||||||
serve(test, init_ssl_context, Gemenon.Sockets.ip"0.0.0.0", 1999)
|
serve(test, init_ssl_context, Gemenon.Sockets.ip"0.0.0.0", 1965)
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import Base.get
|
import Base.get
|
||||||
function get(request::Request; certs::Union{CAChain,Nothing} = nothing)
|
function get(request::Request; certs::Union{CAChain,Nothing} = nothing,
|
||||||
|
sni = true)
|
||||||
req = string(request)
|
req = string(request)
|
||||||
let len = sizeof(req)
|
let len = sizeof(req)
|
||||||
if len > 1024
|
if len > 1024
|
||||||
|
@ -15,6 +16,8 @@ function get(request::Request; certs::Union{CAChain,Nothing} = nothing)
|
||||||
io = Sockets.connect(request.host, request.port)
|
io = Sockets.connect(request.host, request.port)
|
||||||
|
|
||||||
client = SSLClient(ctx, io)
|
client = SSLClient(ctx, io)
|
||||||
|
sni && @show OpenSSL.set_host_name(client, request.host)
|
||||||
|
|
||||||
OpenSSL.do_ssl_handshake(client)
|
OpenSSL.do_ssl_handshake(client)
|
||||||
|
|
||||||
while true
|
while true
|
||||||
|
|
|
@ -84,6 +84,8 @@ function Request(protocol, host, port, path, query)
|
||||||
path, query, true, "")
|
path, query, true, "")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
unescape(::Nothing) = ""
|
||||||
|
|
||||||
"unescape(percent_encoded_uri)::String
|
"unescape(percent_encoded_uri)::String
|
||||||
|
|
||||||
Replace %xx escaped chars with their single-character equivalent.
|
Replace %xx escaped chars with their single-character equivalent.
|
||||||
|
|
Loading…
Reference in New Issue