Skip to content
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

Merged
merged 14 commits into from
Feb 10, 2022
Merged

http server for images #2418

merged 14 commits into from
Feb 10, 2022

Conversation

flexsurfer
Copy link
Member

[EXPERIMENT] http server for images

@flexsurfer flexsurfer self-assigned this Nov 2, 2021
@ghost
Copy link

ghost commented Nov 2, 2021

Pull Request Checklist

  • Have you updated the documentation, if impacted (e.g. docs.status.im)?
  • Have you tested changes with mobile?
  • Have you tested changes with desktop?

@status-im-auto
Copy link
Member

status-im-auto commented Nov 2, 2021

Jenkins Builds

Click to see older builds (63)
Commit #️⃣ Finished (UTC) Duration Platform Result
✔️ 6cd1cbd #1 2021-11-02 07:50:26 ~2 min linux 📦zip
✔️ 6cd1cbd #1 2021-11-02 07:53:43 ~6 min android 📦aar
✔️ 6cd1cbd #1 2021-11-02 07:55:10 ~7 min ios 📦zip
✔️ b8435b4 #2 2022-01-24 15:24:48 ~2 min linux 📦zip
✔️ b8435b4 #2 2022-01-24 15:26:45 ~4 min ios 📦zip
✔️ b8435b4 #2 2022-01-24 15:26:49 ~4 min android 📦aar
✔️ bcb45db #3 2022-01-26 11:58:36 ~1 min linux 📦zip
✔️ bcb45db #3 2022-01-26 12:02:23 ~5 min android 📦aar
✔️ bcb45db #3 2022-01-26 12:02:56 ~6 min ios 📦zip
✔️ 252398d #4 2022-01-27 08:56:34 ~1 min linux 📦zip
✔️ 252398d #4 2022-01-27 08:57:35 ~2 min android 📦aar
✔️ 252398d #4 2022-01-27 08:58:33 ~3 min ios 📦zip
✔️ 5ae5f5d #5 2022-01-28 06:29:07 ~1 min linux 📦zip
✔️ 5ae5f5d #5 2022-01-28 06:30:16 ~2 min ios 📦zip
✔️ 5ae5f5d #5 2022-01-28 06:31:03 ~3 min android 📦aar
✔️ e035a62 #6 2022-02-01 10:03:03 ~1 min linux 📦zip
✔️ e035a62 #6 2022-02-01 10:03:27 ~1 min ios 📦zip
✔️ e035a62 #6 2022-02-01 10:04:49 ~3 min android 📦aar
✔️ e8745d5 #7 2022-02-04 10:31:45 ~2 min linux 📦zip
✔️ e8745d5 #7 2022-02-04 10:33:58 ~4 min android 📦aar
✔️ e8745d5 #7 2022-02-04 10:34:00 ~4 min ios 📦zip
✔️ 6b1010e #8 2022-02-04 12:07:28 ~2 min linux 📦zip
✔️ 6b1010e #8 2022-02-04 12:07:44 ~2 min ios 📦zip
✔️ 6b1010e #8 2022-02-04 12:09:10 ~4 min android 📦aar
✔️ 5de0be7 #9 2022-02-04 12:38:49 ~2 min linux 📦zip
✔️ 5de0be7 #9 2022-02-04 12:39:01 ~2 min ios 📦zip
✔️ 5de0be7 #9 2022-02-04 12:40:15 ~3 min android 📦aar
✔️ 5cd8b63 #10 2022-02-07 10:48:03 ~1 min linux 📦zip
✔️ 5cd8b63 #10 2022-02-07 10:49:27 ~3 min ios 📦zip
✔️ 5cd8b63 #10 2022-02-07 10:50:10 ~3 min android 📦aar
✔️ d7b7b7b #11 2022-02-08 14:46:03 ~3 min linux 📦zip
✔️ d7b7b7b #11 2022-02-08 14:47:16 ~4 min ios 📦zip
✔️ d7b7b7b #11 2022-02-08 14:47:26 ~4 min android 📦aar
✔️ c65fa14 #12 2022-02-09 09:04:20 ~2 min linux 📦zip
✔️ c65fa14 #12 2022-02-09 09:04:21 ~2 min ios 📦zip
✔️ c65fa14 #12 2022-02-09 09:05:30 ~3 min android 📦aar
✔️ fddab92 #13 2022-02-09 09:07:48 ~1 min linux 📦zip
✔️ fddab92 #13 2022-02-09 09:08:34 ~2 min ios 📦zip
✔️ fddab92 #13 2022-02-09 09:09:27 ~3 min android 📦aar
✔️ cfd2b8b #14 2022-02-09 10:19:52 ~2 min linux 📦zip
✔️ cfd2b8b #14 2022-02-09 10:20:09 ~2 min ios 📦zip
✔️ cfd2b8b #14 2022-02-09 10:20:52 ~3 min android 📦aar
✔️ c84a9ae #15 2022-02-09 12:06:25 ~3 min ios 📦zip
✔️ c84a9ae #15 2022-02-09 12:08:44 ~5 min linux 📦zip
✔️ c84a9ae #15 2022-02-09 12:11:06 ~7 min android 📦aar
✔️ 13bcf98 #16 2022-02-09 13:18:51 ~1 min linux 📦zip
✔️ 13bcf98 #16 2022-02-09 13:19:21 ~2 min ios 📦zip
✔️ 13bcf98 #16 2022-02-09 13:20:31 ~3 min android 📦aar
✔️ 55b0cf8 #17 2022-02-09 14:11:25 ~2 min linux 📦zip
✔️ 55b0cf8 #17 2022-02-09 14:11:38 ~2 min ios 📦zip
✔️ 55b0cf8 #17 2022-02-09 14:12:54 ~3 min android 📦aar
✔️ 2bb4b3b #18 2022-02-09 14:14:11 ~1 min linux 📦zip
✔️ 2bb4b3b #18 2022-02-09 14:14:23 ~2 min ios 📦zip
✔️ 2bb4b3b #18 2022-02-09 14:16:19 ~3 min android 📦aar
✔️ f850c3e #19 2022-02-09 14:48:58 ~1 min linux 📦zip
✔️ f850c3e #19 2022-02-09 14:49:15 ~2 min ios 📦zip
✔️ f850c3e #19 2022-02-09 14:50:48 ~3 min android 📦aar
✔️ e63bfba #20 2022-02-09 17:26:11 ~3 min linux 📦zip
✔️ e63bfba #20 2022-02-09 17:26:22 ~3 min ios 📦zip
✔️ e63bfba #20 2022-02-09 17:27:46 ~5 min android 📦aar
✔️ f9cf690 #21 2022-02-09 17:55:01 ~2 min linux 📦zip
✔️ f9cf690 #21 2022-02-09 17:55:46 ~3 min ios 📦zip
✔️ f9cf690 #21 2022-02-09 17:56:14 ~3 min android 📦aar
Commit #️⃣ Finished (UTC) Duration Platform Result
✔️ a31b0c7 #22 2022-02-10 16:40:01 ~1 min linux 📦zip
✔️ a31b0c7 #22 2022-02-10 16:40:23 ~2 min ios 📦zip
✔️ a31b0c7 #22 2022-02-10 16:43:06 ~4 min android 📦aar
✔️ e04cb54 #23 2022-02-10 17:11:52 ~1 min linux 📦zip
✔️ e04cb54 #23 2022-02-10 17:12:24 ~2 min ios 📦zip
✔️ e04cb54 #23 2022-02-10 17:13:46 ~3 min android 📦aar

s.logger.Error("could not generate identicon")
}

w.Header().Set("Content-Type", "image/png")
Copy link
Member

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")
Copy link
Member

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

}

func (s *Server) Start() error {
listener, err := net.Listen("tcp", ":0")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
listener, err := net.Listen("tcp", ":0")
listener, err := net.Listen("tcp", "localhost:0")

}

func (s *Server) Start() error {
listener, err := net.Listen("tcp", ":0")
Copy link

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.

Copy link
Contributor

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.

@cammellos cammellos force-pushed the experiment/run-http-image-server-2 branch from 6cd1cbd to b8435b4 Compare January 24, 2022 15:22
@bitgamma bitgamma changed the title [EXPERIMENT] http server for images http server for images Feb 3, 2022
@bitgamma bitgamma requested a review from cammellos February 3, 2022 16:07

derBytes, err := x509.CreateCertificate(rand.Reader, &template, &template, &priv.PublicKey, priv)
if err != nil {
log.Fatalf("Failed to create certificate: %v", err)
Copy link
Contributor

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?

Copy link
Member

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.

@bitgamma
Copy link
Member

bitgamma commented Feb 4, 2022

TODO: (reminder to self) bump the VERSION file right before mering

@bitgamma bitgamma force-pushed the experiment/run-http-image-server-2 branch from 5de0be7 to 5cd8b63 Compare February 7, 2022 10:46
@bitgamma bitgamma force-pushed the experiment/run-http-image-server-2 branch from c65fa14 to fddab92 Compare February 9, 2022 09:05
@bitgamma bitgamma force-pushed the experiment/run-http-image-server-2 branch from 55b0cf8 to 2bb4b3b Compare February 9, 2022 14:11
@bitgamma bitgamma force-pushed the experiment/run-http-image-server-2 branch from e63bfba to f9cf690 Compare February 9, 2022 17:52
@bitgamma bitgamma self-assigned this Feb 10, 2022
@bitgamma bitgamma merged commit 5925b3b into develop Feb 10, 2022
@bitgamma bitgamma deleted the experiment/run-http-image-server-2 branch February 10, 2022 17:19
Copy link

@0kok0 0kok0 left a 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants