-
Notifications
You must be signed in to change notification settings - Fork 250
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
http server for images #2418
http server for images #2418
Conversation
Pull Request Checklist
|
Jenkins BuildsClick to see older builds (63)
|
s.logger.Error("could not generate identicon") | ||
} | ||
|
||
w.Header().Set("Content-Type", "image/png") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it make sense to add headers like these so the browser keeps the identicons in cache?:
w.Header().Set("Cache-Control", "max-age:290304000, public")
w.Header().Set("Expires", time.Now().AddDate(60, 0, 0).Format(http.TimeFormat))
pk := pks[0] | ||
image, err := identicon.Generate(pk) | ||
if err != nil { | ||
s.logger.Error("could not generate identicon") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could be interesting to add a default image placeholder here for cases where the identicon could not be generated
protocol/images/server.go
Outdated
} | ||
|
||
func (s *Server) Start() error { | ||
listener, err := net.Listen("tcp", ":0") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
listener, err := net.Listen("tcp", ":0") | |
listener, err := net.Listen("tcp", "localhost:0") |
protocol/images/server.go
Outdated
} | ||
|
||
func (s *Server) Start() error { | ||
listener, err := net.Listen("tcp", ":0") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it also be possible to use net.http.ListenAndServeTLS instead or a tls.listener? TLS with self signed certs would harden the architecture here, also it wouldn't be a problem if at some point in time the server is moved out of the local application.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the review, sorry for the late reply, I missed the comment.
I'll look into it, we can definitely use a self signed certificate in the go code, but the tricky bit is to have the client accept a self signed certificate, I'll have a look.
So far I was looking at https://developer.apple.com/documentation/foundation/url_loading_system/handling_an_authentication_challenge/performing_manual_server_trust_authentication for IOS, but I'll have to spend a bit more time researching.
6cd1cbd
to
b8435b4
Compare
protocol/images/server.go
Outdated
|
||
derBytes, err := x509.CreateCertificate(rand.Reader, &template, &template, &priv.PublicKey, priv) | ||
if err != nil { | ||
log.Fatalf("Failed to create certificate: %v", err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you not want to return in this case? similarly below, maybe we should just make the FN return an error and abort if we cant' create?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
right, I forgot about that, sorry. I don't expect errors to ever happen since there is no user input among the parameters, but better safe than sorry. Fixed now.
TODO: (reminder to self) bump the VERSION file right before mering |
5de0be7
to
5cd8b63
Compare
c65fa14
to
fddab92
Compare
55b0cf8
to
2bb4b3b
Compare
e63bfba
to
f9cf690
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
neat work on the tls
[EXPERIMENT] http server for images