Comments (9)
A quick implementation:
devsisters/goquic
package main
import (
"crypto/tls"
"github.com/go-siris/siris"
"github.com/go-siris/siris/context"
"golang.org/x/crypto/acme/autocert"
"github.com/devsisters/goquic"
)
func main() {
app := siris.New()
app.Get("/", func(ctx context.Context) {
ctx.Writef("Hello from the server")
})
app.Get("/mypath", func(ctx context.Context) {
ctx.Writef("Hello from %s", ctx.Path())
})
// Note: It's not needed if the first action is "go app.Run".
if err := app.Build(); err != nil {
panic(err)
}
var tlsConfig *tls.Config
autoTLSManager := autocert.Manager{
Prompt: autocert.AcceptTOS,
HostPolicy: autocert.HostWhitelist("example.com"),
Email: "[email protected]",
Cache: autocert.DirCache("./cert/"),
}
tlsConfig = new(tls.Config)
tlsConfig.GetCertificate = autoTLSManager.GetCertificate
srv2, _ := goquic.NewServer(":443", "/etc/letsencrypt/live/example.com/fullchain.pem", "/etc/letsencrypt/live/example.com/privkey.pem", 1, app, app, tlsConfig)
go srv2.ListenAndServe()
println("Start a server listening on https://example.com:8443")
app.Run(siris.Addr(":80")) // Block here.
}
lucas-clemente/quic-go/h2quic
package main
import (
"crypto/tls"
"net/http"
"github.com/go-siris/siris"
"github.com/go-siris/siris/context"
"github.com/go-siris/siris/core/handlerconv"
"golang.org/x/crypto/acme/autocert"
"github.com/lucas-clemente/quic-go/h2quic"
)
var h2qserv *h2quic.Server
func main() {
app := siris.New()
sirisMiddleware := handlerconv.FromStdWithNext(func(w http.ResponseWriter, r *http.Request, next http.HandlerFunc) {
h2qserv.SetQuicHeaders(w.Header())
next(w, r) // go to the next route's handler
return
})
app.Use(sirisMiddleware)
app.Get("/", func(ctx context.Context) {
ctx.Writef("Hello from the server")
})
app.Get("/mypath", func(ctx context.Context) {
ctx.Writef("Hello from %s", ctx.Path())
})
// Note: It's not needed if the first action is "go app.Run".
if err := app.Build(); err != nil {
panic(err)
}
var tlsConfig *tls.Config
autoTLSManager := autocert.Manager{
Prompt: autocert.AcceptTOS,
HostPolicy: autocert.HostWhitelist("example.com"),
Email: "[email protected]",
Cache: autocert.DirCache("./cert/"),
}
tlsConfig = new(tls.Config)
tlsConfig.GetCertificate = autoTLSManager.GetCertificate
// start a secondary server listening on localhost:9090.
// use "go" keyword for Listen functions if you need to use more than one server at the same app.
//
// http://localhost:9090/
// http://localhost:9090/mypath
srv1 := &http.Server{Addr: ":443", TLSConfig: tlsConfig, Handler: app}
go srv1.ListenAndServeTLS("/etc/letsencrypt/live/example.com/fullchain.pem", "/etc/letsencrypt/live/example.com/privkey.pem")
println("Start a server listening on https://example.com:443")
h2qserv = &h2quic.Server{Server: srv1}
go h2qserv.ListenAndServeTLS("/etc/letsencrypt/live/example.com/fullchain.pem", "/etc/letsencrypt/live/example.com/privkey.pem")
println("Start a server listening on https://example.com:443 (QUIC)")
// Note: app.Run is totally optional, we have already built the app with app.Build,
// you can just make a new http.Server instead.
// http://localhost:8080/
// http://localhost:8080/mypath
app.Run(siris.Addr(":80")) // Block here.
}
Test it with chrome chromeBinary --enable-quic --origin-to-force-quic-on=example.com:443 https://example.com
from siris.
So we need to wait, but i prefer lucas-clemente/quic-go/h2quic because it has the heighest versions.
from siris.
See also:
- https://devsisters.github.io/goquic/
- https://github.com/lucas-clemente/quic-go
- https://github.com/devsisters/goquic
from siris.
https://github.com/devsisters/goquic seems outdatet. on the other hand devsisters bases on the quic implementation of chromium.
https://github.com/lucas-clemente/quic-go seems newer and simply implemented, but we don't know how long this repository will be maintained.
from siris.
from siris.
i have created 2 feature branches, if someone like to add there a example implementation i'm very happy.
feature/quic-devsisters for https://github.com/devsisters/goquic
feature/quic-lucas-clemente for https://github.com/lucas-clemente/quic-go
from siris.
only problem i found yet is that the devsisters example only listen to UDP4 and not to the UDP6...
Proto Recv-Q Send-Q Local Address Foreign Address State User Inode PID/Program name
tcp 0 0 localhost:mysql *:* LISTEN mysql 67108 25671/mysqld
tcp 0 0 *:ssh *:* LISTEN root 9472 4000/sshd
tcp6 0 0 [::]:https [::]:* LISTEN root 453150 29226/server-app
tcp6 0 0 [::]:http [::]:* LISTEN root 454266 29226/server-app
tcp6 0 0 [::]:ssh [::]:* LISTEN root 9474 4000/sshd
udp 0 0 *:https *:* root 454268 29226/server-app
udp 0 0 *:bootpc *:* root 6253 3948/dhclient
udp 0 0 localhost:ntp *:* root 10336 4038/ntpd
udp 0 0 *:ntp *:* root 10332 4038/ntpd
udp6 0 0 localhost:ntp [::]:* root 10340 4038/ntpd
udp6 0 0 [::]:ntp [::]:* root 10329 4038/ntpd
from siris.
what happens if you listen on [::]:443 ?
EDIT ah ok i've seen the code. It wouldn't change anything
from siris.
see #59
from siris.
Related Issues (20)
- Correct framwork in repo title to framework HOT 1
- Use Cache Markdown for partial data HOT 3
- Will siris be merged again with iris? HOT 12
- Race condition
- Add issue template HOT 3
- Add code coverage reported via https://codecov.io HOT 3
- Need AppVeyor Support for testing on windows clients HOT 2
- Possible License Violation HOT 4
- Why I get the notification from this repo HOT 5
- Allow support for a LimitListener HOT 5
- Session Store Backend: Badger HOT 1
- devel: quicServer does not start...
- Full server hang after setting Flash Message and redirecting HOT 4
- Please provide a boilerplate with User Registration/Login/Logout. We need it badly. HOT 1
- may u add these functions? HOT 3
- <title suppressed due to foul language>
- [Feature Request] XAMPP-like solution: React, go-SIRIS, MongoDB, Server-side rendering, on-demand loading HOT 1
- how to integrate Siris with ReactJs?
- Websockets over Redis HOT 1
- Build failure due to recent changes to satori/go.uuid project
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from siris.