Skip to content
This repository has been archived by the owner on Dec 14, 2020. It is now read-only.

webui: Add option to redirect to HTTPS #1521

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions release/src/router/httpd/httpd.c
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ char current_page_name[128];
char user_agent[1024];
char gen_token[32]={0};
char last_fail_token[32]={0};
int do_ssl = 0; // use Global for HTTPS upgrade judgment in web.c

#ifdef TRANSLATE_ON_FLY
char Accept_Language[16];
Expand Down Expand Up @@ -392,7 +393,11 @@ send_login_page(int fromapp_flag, int error_status, char* url, char* file, int l
}
}
}
snprintf(inviteCode, sizeof(inviteCode), "<script>top.location.href='/Main_Login.asp';</script>");
if(!do_ssl && nvram_match("http_redirect_to_https", "1") && nvram_match("http_enable", "2")){
snprintf(inviteCode, sizeof(inviteCode), "<script>top.location.href='https://' + location.host + '/Main_Login.asp';</script>");
}else{
snprintf(inviteCode, sizeof(inviteCode), "<script>top.location.href='/Main_Login.asp';</script>");
}
}else{
snprintf(inviteCode, sizeof(inviteCode), "\"error_status\":\"%d\"", error_status);
}
Expand Down Expand Up @@ -2045,7 +2050,6 @@ void reapchild() // 0527 add
wait(NULL);
}

int do_ssl = 0; // use Global for HTTPS upgrade judgment in web.c
int ssl_stream_fd; // use Global for HTTPS stream fd in web.c
int main(int argc, char **argv)
{
Expand Down
1 change: 1 addition & 0 deletions release/src/router/shared/defaults.c
Original file line number Diff line number Diff line change
Expand Up @@ -1964,6 +1964,7 @@ struct nvram_tuple router_defaults[] = {
/* { "http_lanport", "80" }, */
{ "http_dut_redir", "0" }, // 1: redir lan_ip to router.asus.com
#ifdef RTCONFIG_HTTPS
{ "http_redirect_to_https", "0" },
{ "https_lanport", "8443" },
{ "https_crt_file", "" },
{ "https_crt_save", "0" },
Expand Down
15 changes: 14 additions & 1 deletion release/src/router/www/Advanced_System_Content.asp
Original file line number Diff line number Diff line change
Expand Up @@ -168,12 +168,14 @@ function initial(){
if(!HTTPS_support){
document.getElementById("https_tr").style.display = "none";
document.getElementById("https_lanport").style.display = "none";
document.getElementById("http_to_https_redirect").style.display = "none";
}
else{
hide_https_lanport(document.form.http_enable.value);
hide_https_wanport(document.form.http_enable.value);
hide_https_crt();
show_cert_details();
hide_http_to_https_redirect(document.form.http_enable.value);
}

if(wifi_tog_btn_support || wifi_hw_sw_support || sw_mode == 2 || sw_mode == 4){ // wifi_tog_btn && wifi_hw_sw && hide WPS button behavior under repeater mode
Expand Down Expand Up @@ -904,6 +906,10 @@ function hide_https_wanport(_value){
document.getElementById("https_port").style.display = (_value == "0") ? "none" : "";
}

function hide_http_to_https_redirect(_value){
document.getElementById("http_to_https_redirect").style.display = (_value == "2") ? "" : "none";
}

function hide_https_crt(){
var protos = document.form.http_enable.value;

Expand Down Expand Up @@ -1597,14 +1603,21 @@ function upload_cert_key(){
<tr id="https_tr">
<th><#WLANConfig11b_AuthenticationMethod_itemname#></th>
<td>
<select name="http_enable" class="input_option" onchange="hide_https_lanport(this.value);hide_https_wanport(this.value);hide_https_crt();">
<select name="http_enable" class="input_option" onchange="hide_https_lanport(this.value);hide_https_wanport(this.value);hide_https_crt();hide_http_to_https_redirect(this.value);">
<option value="0" <% nvram_match("http_enable", "0", "selected"); %>>HTTP</option>
<option value="1" <% nvram_match("http_enable", "1", "selected"); %>>HTTPS</option>
<option value="2" <% nvram_match("http_enable", "2", "selected"); %>>BOTH</option>
</select>
</td>
</tr>

<tr id="http_redirect_to_https">
<th>Redirect to HTTPS?</th>
<td>
<input type="checkbox" value="1" class="input_6_table" name="http_to_https_redirect" checked="<% nvram_get("http_to_https_redirect", "1", "checked"); %>"><#checkbox_Yes#>
</td>
</tr>

<tr id="https_lanport">
<th>HTTPS Lan port</th>
<td>
Expand Down