Coder Social home page Coder Social logo

Comments (5)

lws-team avatar lws-team commented on June 10, 2024 1

Thanks, it's pushed on main

from libwebsockets.

lws-team avatar lws-team commented on June 10, 2024

I guess so if you need to stop it producing the listen socket itself but then adopt one that is listening on some port... it probably only needs to take care about CONTEXT_PORT_NO_LISTEN_SERVER case though?

from libwebsockets.

markmaker avatar markmaker commented on June 10, 2024

Thanks for the quick answer.

To understand better: why does it not happen with HTTP/2?

Should I make a PR?

from libwebsockets.

lws-team avatar lws-team commented on June 10, 2024

It looks like it checks at upgrade time for h1 if LWS_SERVER_OPTION_VHOST_UPG_STRICT_HOST_CHECK set. But for h2, it normally negotiates what protocol you want at tls negotiation time, using alpn, and there is no h1->h2c upgrade used. There is an h2c upgrade mechanism supported, but eg browsers do it at tls time instead by alpn.

Once h2 is connected, streams inside the connection inherit the outside port.

If you checked it works for your adoption case, yes open a PR or just let me know your From: string and paste the change and I'll do it.

from libwebsockets.

markmaker avatar markmaker commented on June 10, 2024

Ah, I understand. Here's the patch:

From 18e26a7a6dce0617e7d14d98655efd0e59b7170d Mon Sep 17 00:00:00 2001
From: markmaker <mark@makr.zone>
Date: Mon, 8 Jan 2024 14:53:30 +0100
Subject: [PATCH] Ignore a vhost port mismatch when using
 CONTEXT_PORT_NO_LISTEN_SERVER.

---
 lib/roles/http/server/server.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lib/roles/http/server/server.c b/lib/roles/http/server/server.c
index 9bf1eba2..ff5b1255 100644
--- a/lib/roles/http/server/server.c
+++ b/lib/roles/http/server/server.c
@@ -2153,7 +2153,8 @@ lws_confirm_host_header(struct lws *wsi)
 		if (e != LWS_TOKZE_ENDED)
 			goto bad_format;
 
-	if (wsi->a.vhost->listen_port != port) {
+	if (wsi->a.vhost->listen_port != port &&
+		wsi->a.vhost->listen_port != CONTEXT_PORT_NO_LISTEN_SERVER) {
 		lwsl_info("%s: host port %d mismatches vhost port %d\n",
 			  __func__, port, wsi->a.vhost->listen_port);
 		return 1;
-- 
2.40.1

from libwebsockets.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.