Browse Source

fixes in connectivity block

Danja Vasiliev 9 years ago
parent
commit
6b83813d9c

+ 1 - 1
openwrt/common/etc/config/network

@@ -12,7 +12,7 @@ config interface 'lan'
 	option force_link '1'
 	option type 'bridge'
 	option proto 'static'
-	option ipaddr '192.168.1.1'
+	option ipaddr '192.168.56.1'
 	option netmask '255.255.255.0'
 
 config interface 'wan'

+ 3 - 3
openwrt/common/etc/config/wireless

@@ -3,9 +3,9 @@ config wifi-device 'radio0'
 	option channel 'auto'
 	option hwmode '11gn'
 	option path 'platform/ar933x_wmac'
-	option noscan '1'
+	## option noscan '1'
 	option htmode 'HT20'
-	option country 'US' ## US regdom is 
+	option country 'DE'
 
 config wifi-iface
 	option device 'radio0'
@@ -20,7 +20,7 @@ config wifi-iface
 	option network 'wan'
 	option disabled '1'
 	option mode 'sta'
-	option encryption 'psk2'
+	option encryption ''
 	option ssid ''
 	option key ''
 

+ 36 - 16
openwrt/common/opt/lib/admin/admin2.cgi

@@ -134,13 +134,19 @@ wanSet() {
     ##     option proto 'dhcp' (and no 'option ifname' specified!)
 
     logThis "wan.ifname=$POST_wanifname"
-    if [[ $POST_wanifname == 'eth0' ]]; then
+    if [[ $POST_wanifname =~ 'eth' ]]; then
       doUci set wanifname $POST_wanifname
       doUci set wanwifacedis '1'
-    elif [[ $POST_wanifname == 'wlan1' ]]; then
+    elif [[ $POST_wanifname =~ 'wlan' ]]; then
       doUci set wanifname ''
       doUci set wanwifacedis ''
     fi
+    ## case of dir505
+    if [[ $POST_wanifname == 'eth1' ]]; then
+      doUci set lanifname ''
+    elif [[ $POST_wanifname == 'wlan0' ]]; then
+      doUci set lanifname 'eth1'
+    fi
     if [[ $POST_wanproto == 'dhcp' ]]; then
       doUci set wanproto dhcp
       doUci set wanipaddr ''
@@ -159,7 +165,7 @@ wanSet() {
       doUci set wandns $POST_wandns
     fi
 
-    if [[ $POST_wanifname == 'wlan1' ]]; then
+    if [[ $POST_wanifname =~ 'wlan' ]]; then
       ssidChange || showMesg 'wanSet: Wireless configuration failed'
     else
       doUci commit network &&
@@ -177,11 +183,18 @@ ssidChange() {
   ## check for iface
   [[ $POST_iface =~ ^('wan'|'lan')$ ]] || showMesg 'Error changing wireless settings' '5' 'unknown or unconfigured interface'
   logThis "$POST_iface is being set"
+  setQueryVars
 
   _p=$POST_iface
 
   ## default enc for now
-  local _enc='psk2'
+  local _enc='none'
+  if [[ $POST_wanenc == 'wpa2' ]]; then
+    _enc='psk2'
+  elif [[ $POST_wanenc == 'wpa1' ]]; then
+    _enc='psk'
+  fi
+
   if [[ $POST_iface == 'wan' ]]; then
     local _mode='sta'
     local _ssid="${POST_wanssid}"
@@ -214,7 +227,7 @@ ssidChange() {
       lanAddr
     fi
   fi
-
+  doUci commit network
   doUci commit wireless
   _ERR=$?
 
@@ -424,6 +437,7 @@ doUci() {
     wanssid) _ARG='wireless.@wifi-iface[1].ssid';;
     wanenc) _ARG='wireless.@wifi-iface[1].encryption';;
     wankey) _ARG='wireless.@wifi-iface[1].key';;
+    lanifname) _ARG='network.lan.ifname';;
     lanipaddr) _ARG='network.lan.ipaddr';;
     wanifname) _ARG='network.wan.ifname';;
     wanproto) _ARG='network.wan.proto';;
@@ -475,8 +489,7 @@ doUci() {
 ## ie: htmlhead "<meta http-equiv='refresh' content='2;URL=http://${HTTP_REFERER}'>"
 
 htmlHead() {
-_echo "<!-- obnoxious code below, keep your ports tight -->
-<!doctype html>
+_echo "<!doctype html>
 <html>
 <head>
 <meta http-equiv='Content-Type' content='text/html; charset=UTF-8' />
@@ -521,12 +534,10 @@ if [[ "${REQUEST_METHOD^^}" == "POST" ]]; then
   esac
 fi
 
-## if URL is not (just) /admin
-#if [[ "${REQUEST_METHOD^^}" == "GET" ]]; then
-  if [[ "${REQUEST_URI/\/admin\//}" ]]; then
-   headerPrint '301' '/admin/' 
-  fi
-#fi
+## all other requests redirect to /admin/
+if [[ "${REQUEST_URI/\/admin\//}" ]]; then
+ headerPrint '301' '/admin/' 
+fi
 
 headerPrint '200'
 htmlHead
@@ -542,6 +553,14 @@ IFS=','
 wan=( $(ifaceStat wan) )
 IFS=$_IFS
 
+eth='eth0'
+wlan='wlan1'
+
+if [[ ${devmod} =~ 'DIR-505' ]]; then
+  eth='eth1'
+  wlan='wlan0'
+fi
+
 sgvpn=$(doUci get sgopenvpnenable)
 ddomain=$(doUci get sgddnsdomain)
 dsubdomain=$(doUci get sgddnssubdomain)
@@ -570,8 +589,8 @@ wankey=$(doUci get wankey)
   <div style='display:inline-flex'>
   <div style='display:inline-block;'>
   <select name='wanifname' id='wanifname' style='display:block'>
-  <option value='eth0' id='eth' <% ( [[ $wanifname =~ ('eth') ]] && _echo 'selected' ) %> >Wired (WAN port)</option>
-  <option value='wlan1' id='wlan' <% ( [[ $wanifname =~ ('wlan') ]] && _echo 'selected' ) %> >Wireless (WiFi)</option>
+  <option value='<% _echo $eth %>' id='eth' <% ( [[ $wanifname =~ ('eth') ]] && _echo 'selected' ) %>>Wired (WAN port)</option>
+  <option value='<% _echo $wlan %>' id='wlan' <% ( [[ $wanifname =~ ('wlan') ]] && _echo 'selected' ) %>>Wireless (WiFi)</option>
   </select>
   <fieldset id='wanwifi' <% ( [[ $wanifname =~ ('wlan') ]] && _echo "class='show elem'" || _echo "class='hide elem'" ) %>>
     
@@ -582,7 +601,8 @@ wankey=$(doUci get wankey)
     _echo "<option id=$wanssid selected>$wanssid</option>"
   fi %>
   </select>
-  <input type='password' name='wankey' placeholder='passphrase' value='<% _echo $wankey %>'>
+  <input type='hidden' id='wanenc' name='wanenc' class='elem' value='none'>
+  <input type='password' name='wankey' placeholder='wpa passphrase' value='<% _echo $wankey %>'>
 
   </fieldset>
 

+ 6 - 0
openwrt/common/opt/lib/resources/admin/admin.css

@@ -44,8 +44,14 @@ select {
   background-size: 12px;
   background-position: 180px;
   cursor: pointer;
+/*  height: 100%; */
 }
 
+select option {
+/*  height: 50px; */
+}
+
+
 input {
   text-indent: 4px;
   background: #fcfcfc;

+ 41 - 26
openwrt/common/opt/lib/resources/admin/admin.js

@@ -1,6 +1,6 @@
 document.addEventListener('DOMContentLoaded', function() {
 
-/* make wanted 'elem' class elements to array or vars */
+/* add class='elem' elements to array 'el' */
 var el = [];
 (function() {
   x = document.getElementsByClassName('elem');
@@ -11,15 +11,6 @@ var el = [];
   }
 })();
 
-/*
-var uploadbtn = document.getElementById('uploadbtn');
-var uploadfile = document.getElementById('uploadfile');
-var wanconf = document.getElementById('wanconf');
-var wanssid = document.getElementById('wanssid');
-var wanwifi = document.getElementById('wanwifi');
-var wanaddr = document.getElementById('wanaddr');
-*/
-
 el['uploadbtn'].addEventListener('change', function (e) {
   el['uploadfile'].value = this.value.replace(/^.*\\/, "");
   var len = el['uploadfile'].value.length - 7;
@@ -41,16 +32,23 @@ for (var i=0; i < submitbtns.length; i++){
 }
 
 el['wanconf'].addEventListener('change', function(e) { 
-  wanChange(e.target)
+  wanChange(e.target);
+  e.stopPropagation();
+});
+
+el['wanssid'].addEventListener('change', function(e) { 
+  if (enc = document.getElementById(e.target.value).getAttribute('data-enc')) {
+    el['wanenc'].value = enc;
+  }
   e.stopPropagation();
 });
 
 el['wanssid'].addEventListener('focus', function(e) {
   if (e.target.length == 1) {
     iwScan(e.target);
-    e.target.blur();
-    getFirstchild(e.target).blur();
-    getFirstchild(e.target).style.display = 'none';
+    // e.target.blur();
+    //getFirstchild(e.target).blur();
+    //getFirstchild(e.target).style.display = 'none';
   } else {
     iwScan(e.target);
   }
@@ -62,7 +60,7 @@ function wanChange(e) {
   switch (e[e.selectedIndex].id) {
     case 'wlan':
       el['wanwifi'].setAttribute('class','show');
-      //iwScan(el['wanssid']);
+      iwScan(el['wanssid']);
       break;
     case 'dhcp':
     //  wanaddr.setAttribute('class','hide');
@@ -93,26 +91,43 @@ function iwScan(e) {
     e.insertBefore(scan_el, e.firstChild);
   } else scan_el = document.getElementById('scan');
   scan_el.textContent = 'scanning for networks..';
-  scan_el.selected = 1;
+  scan_el.selected = true;
   ajaxReq('POST', '/admin/iwscan', 'null', function(xhr) {
     res = JSON.parse(xhr['response']);
     aps = res['results'].sort(compSort); /* get APs */
     aps_num = Object.keys(aps).length;
+    function updateAp() {
+      ap.setAttribute('data-bssid',  aps[i]['bssid']);
+      ap.setAttribute('data-quality',  aps[i]['quality']);
+      if (aps[i]['encryption']['enabled']) {
+        // WPA[1,2] present
+        if (aps[i]['encryption']['wpa']) {
+          // choose last (highest) WPA version
+          wpa = aps[i]['encryption']['wpa'][aps[i]['encryption']['wpa'].length - 1];
+          //console.log(ap.id + ':' + 'wpa' + wpa);
+          ap.setAttribute('data-enc', 'wpa' + wpa);
+        // assume WEP
+        } else {
+          ap.setAttribute('data-enc', 'wep');
+        }
+      // Open AP
+      } else {
+        ap.setAttribute('data-enc', 'none');
+      }
+    }
     for (i = 0; i < aps_num; i++) {
       // check if AP is already in the DOM
       if (document.getElementById(aps[i]['ssid'])) {
         //console.log('found ' + aps[i]['ssid'] + ' entry');
-        /* TODO: update existing records */
+        /* TODO: remove duplicate code */
+        ap = document.getElementById(aps[i]['ssid']);
+        //console.log('update: ');
+        updateAp();
       } else {
         ap = document.createElement('option');
         ap.id = aps[i]['ssid'];
-        ap.setAttribute('data-bssid',  aps[i]['bssid']);
-        ap.setAttribute('data-quality',  aps[i]['quality']);
-        if (aps[i]['encryption']['enabled']) {
-          ap.setAttribute('data-enc', 'wpa2');
-        } else {
-          ap.setAttribute('data-enc', 'false');
-        }
+        //console.log('add: ');
+        updateAp();
         ap.textContent = aps[i]['ssid'] ? aps[i]['ssid'] : '[hidden network]';
         e.appendChild(ap);
       }
@@ -123,10 +138,10 @@ function iwScan(e) {
       console.log('no scan results');
     }
   });
-  e.blur();
+  // e.blur();
   // just focusing someother element 
   // document.getElementById('wansubmit').focus();
-  return
+  return false;
 }
 
 /* v simple XHR */

+ 0 - 92
openwrt/common/opt/lib/resources/fonts/Titillium_Web/OFL.txt

@@ -1,92 +0,0 @@
-Copyright (c) 2009-2011 by Accademia di Belle Arti di Urbino and students of MA course of Visual design. Some rights reserved.
-This Font Software is licensed under the SIL Open Font License, Version 1.1.
-This license is copied below, and is also available with a FAQ at:
-http://scripts.sil.org/OFL
-
-
------------------------------------------------------------
-SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
------------------------------------------------------------
-
-PREAMBLE
-The goals of the Open Font License (OFL) are to stimulate worldwide
-development of collaborative font projects, to support the font creation
-efforts of academic and linguistic communities, and to provide a free and
-open framework in which fonts may be shared and improved in partnership
-with others.
-
-The OFL allows the licensed fonts to be used, studied, modified and
-redistributed freely as long as they are not sold by themselves. The
-fonts, including any derivative works, can be bundled, embedded, 
-redistributed and/or sold with any software provided that any reserved
-names are not used by derivative works. The fonts and derivatives,
-however, cannot be released under any other type of license. The
-requirement for fonts to remain under this license does not apply
-to any document created using the fonts or their derivatives.
-
-DEFINITIONS
-"Font Software" refers to the set of files released by the Copyright
-Holder(s) under this license and clearly marked as such. This may
-include source files, build scripts and documentation.
-
-"Reserved Font Name" refers to any names specified as such after the
-copyright statement(s).
-
-"Original Version" refers to the collection of Font Software components as
-distributed by the Copyright Holder(s).
-
-"Modified Version" refers to any derivative made by adding to, deleting,
-or substituting -- in part or in whole -- any of the components of the
-Original Version, by changing formats or by porting the Font Software to a
-new environment.
-
-"Author" refers to any designer, engineer, programmer, technical
-writer or other person who contributed to the Font Software.
-
-PERMISSION & CONDITIONS
-Permission is hereby granted, free of charge, to any person obtaining
-a copy of the Font Software, to use, study, copy, merge, embed, modify,
-redistribute, and sell modified and unmodified copies of the Font
-Software, subject to the following conditions:
-
-1) Neither the Font Software nor any of its individual components,
-in Original or Modified Versions, may be sold by itself.
-
-2) Original or Modified Versions of the Font Software may be bundled,
-redistributed and/or sold with any software, provided that each copy
-contains the above copyright notice and this license. These can be
-included either as stand-alone text files, human-readable headers or
-in the appropriate machine-readable metadata fields within text or
-binary files as long as those fields can be easily viewed by the user.
-
-3) No Modified Version of the Font Software may use the Reserved Font
-Name(s) unless explicit written permission is granted by the corresponding
-Copyright Holder. This restriction only applies to the primary font name as
-presented to the users.
-
-4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
-Software shall not be used to promote, endorse or advertise any
-Modified Version, except to acknowledge the contribution(s) of the
-Copyright Holder(s) and the Author(s) or with their explicit written
-permission.
-
-5) The Font Software, modified or unmodified, in part or in whole,
-must be distributed entirely under this license, and must not be
-distributed under any other license. The requirement for fonts to
-remain under this license does not apply to any document created
-using the Font Software.
-
-TERMINATION
-This license becomes null and void if any of the above conditions are
-not met.
-
-DISCLAIMER
-THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
-OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
-COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
-DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
-OTHER DEALINGS IN THE FONT SOFTWARE.

BIN
openwrt/common/opt/lib/resources/img/defaultImage.png


BIN
openwrt/common/opt/lib/resources/img/favicon.ico


+ 0 - 10
openwrt/common/root/sgproxy.sh

@@ -1,10 +0,0 @@
-#!/bin/bash
-
-_SRV='usr.superglue.it'
-
-while read x
-  do echo "$x"
-  done < <(ssh -N -T -R "$_SRV":0:localhost:80 sgproxy@"$_SRV" -p443  -o ExitOnForwardFailure=yes 2>&1)
-
-  #ssh -N -T -R usr.superglue.it:0:localhost:80 sgproxy@usr.superglue.it -p443  -o ExitOnForwardFailure=yes #-y -y
-

+ 0 - 1
openwrt/common/usr/bin/dropbear

@@ -1 +0,0 @@
-../sbin/dropbear

+ 0 - 1
openwrt/common/usr/sbin/dropbear

@@ -1 +0,0 @@
-dropbear-2013.59

BIN
openwrt/common/usr/sbin/dropbear-2013.59


BIN
openwrt/common/usr/sbin/dropbear-2014.63


+ 8 - 0
openwrt/tools/make_fw.sh

@@ -54,6 +54,9 @@ _OPENWRT_REVISION="$_PWD/openwrt.revision"
 ## browser extension (if any)
 _EXT_SRC="$_PWD/../../editor/build/superglue-firefox.xpi"
 
+## include devTools?
+_DEV_TOOLS=false
+
 ## get OpenWRT revision
 _OPENWRT=$(fgrep -m1 'REVISION:=' $_IMAGEBUILDER/include/version.mk || echo 'r00000')
 _OPENWRT=${_OPENWRT/REVISION:=/}
@@ -96,6 +99,11 @@ for _TARGET in $_TARGETS; do
   cp -Ra $_TARGET/* $_TARGET.tmp/
    sleep 1
 
+  if [ $_DEVTOOLS = false ]; then
+    echo 'removing devTools..'
+    rm -Rf $_TARGET.tmp/opt/lib/devTools
+  fi
+  
   if [[ -e $_EXT_SRC ]]; then
     echo 'copying browser extension..'
     _EXT_DST="$_TARGET.tmp/opt/lib/extension/superglue.xpi"