Warlock client uses wrong server address #51

Closed
opened 2019-07-10 01:53:47 +00:00 by jamie · 6 comments
jamie commented 2019-07-10 01:53:47 +00:00 (Migrated from git.hazaar.io)

Currently using $_SERVER['SERVER_NAME'] which it would appear only covers about 90% of situations. For instance, in Apache if the ServerName configuration attribute is set to www.example.com and there is an alias of warlock.example.com, the application will be available at both addresses. The URL generating will also generate addresses using the appropriate server address as it should.

However, if you go to http://warlock.example.com then Warlock will still attempt to connect to ws://www.example.com even though the requested address is different. This is because the server configuration in $_SERVER['SERVER_NAME'] reports the server name as www.example.com. We need to instead use $_SERVER['HTTP_HOST'] however this can include a port number. I have come up with a nice bit of code that maintains the existing functionality should HTTP_HOST not be available, but if it is, uses it AND strips the port number if needed.

$server = ake(explode(':', $_SERVER['HTTP_HOST']), 0, $_SERVER['SERVER_NAME']);
Currently using `$_SERVER['SERVER_NAME']` which it would appear only covers about 90% of situations. For instance, in Apache if the `ServerName` configuration attribute is set to `www.example.com` and there is an alias of `warlock.example.com`, the application will be available at both addresses. The URL generating will also generate addresses using the appropriate server address as it should. However, if you go to `http://warlock.example.com` then Warlock will still attempt to connect to `ws://www.example.com` even though the requested address is different. This is because the server configuration in `$_SERVER['SERVER_NAME']` reports the server name as `www.example.com`. We need to instead use `$_SERVER['HTTP_HOST']` however this can include a port number. I have come up with a nice bit of code that maintains the existing functionality should HTTP_HOST not be available, but if it is, uses it AND strips the port number if needed. ```php $server = ake(explode(':', $_SERVER['HTTP_HOST']), 0, $_SERVER['SERVER_NAME']); ```
jamie commented 2019-07-10 01:53:50 +00:00 (Migrated from git.hazaar.io)

assigned to @jamie

assigned to @jamie
jamie commented 2019-07-10 01:54:24 +00:00 (Migrated from git.hazaar.io)

changed the description

changed the description
jamie commented 2019-07-10 01:54:27 +00:00 (Migrated from git.hazaar.io)

mentioned in merge request !25

mentioned in merge request !25
jamie commented 2019-07-10 01:54:27 +00:00 (Migrated from git.hazaar.io)

created merge request !25 to address this issue

created merge request !25 to address this issue
jamie commented 2019-07-10 01:56:22 +00:00 (Migrated from git.hazaar.io)

closed via merge request !25

closed via merge request !25
jamie commented 2019-07-10 01:56:22 +00:00 (Migrated from git.hazaar.io)

mentioned in commit 355449b37f

mentioned in commit 355449b37f2af8afc92e76f0c4cf524afdddda7b
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: hazaar/hazaar-warlock#51
No description provided.