Skip to content

Commit

Permalink
Merge pull request #1 from max0y/dev
Browse files Browse the repository at this point in the history
merge dev,  add support for PEAP and MSCHAPV2
  • Loading branch information
max0y authored Mar 7, 2018
2 parents 7388e7a + b1f0b55 commit 40af235
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 3 deletions.
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,9 @@
.vscode
# Windows thumbnail cache files
Thumbs.db
ehthumbs.db
ehthumbs_vista.db

# Folder config file
[Dd]esktop.ini

6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
include $(TOPDIR)/rules.mk

PKG_NAME:=luci-app-cd8021x
PKG_VERSION=1.1
PKG_VERSION=1.2.0
PKG_RELEASE:=1

PKG_LICENSE:=GPLv3
PKG_LICENSE_FILES:=LICENSE
PKG_MAINTAINER:=max0y <[email protected]>

PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)

include $(INCLUDE_DIR)/package.mk
Expand Down
1 change: 1 addition & 0 deletions files/root/etc/config/cd8021x
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ config login
option username ''
option password ''
option ifname 'eth0'
option eap 'MD5'
21 changes: 20 additions & 1 deletion files/root/etc/init.d/cd8021x
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
#!/bin/sh /etc/rc.common

# Copyright (C) 2018 max0y <[email protected]>
# Licensed to the public under the GNU General Public License v3.

START=50

run_cd8021x()
Expand All @@ -10,13 +14,28 @@ run_cd8021x()
local username
local password
local ifname
local eap

config_get username $1 username
config_get password $1 password
config_get ifname $1 ifname
config_get eap $1 eap

killall wpa_supplicant
echo -e "ctrl_interface=/var/run/wpa_supplicant\nap_scan=0\nnetwork={\nkey_mgmt=IEEE8021X\neap=MD5\nidentity=\"$username\"\npassword=\"$password\"\neapol_flags=0\n}" > /tmp/cd8021x.conf
echo -e "ctrl_interface=/var/run/wpa_supplicant\nctrl_interface_group=root\nap_scan=0\nnetwork={\nkey_mgmt=IEEE8021X\neap=$eap\nidentity=\"$username\"\npassword=\"$password\"" > /tmp/cd8021x.conf
case "$eap" in
"MD5")
echo -e "eapol_flags=0\n}" >> /tmp/cd8021x.conf
;;
"PEAP")
echo -e "anonymous_identity=\"$username\"\npairwise=CCMP TKIP\nphase2=\"auth=MSCHAPV2\"\npriority=2\n}" >> /tmp/cd8021x.conf
;;
"MSCHAPV2")
echo -e "eapol_flags=0\nphase1=\"peaplabel=1\"\nphase2=\"auth=MSCHAPV2\"\n}" >> /tmp/cd8021x.conf
;;
*)
esac

wpa_supplicant -B -c /tmp/cd8021x.conf -i$ifname -Dwired

echo "cd802.1x client has started."
Expand Down
5 changes: 4 additions & 1 deletion files/root/usr/lib/lua/luci/controller/cd8021x.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
-- Copyright (C) 2018 max0y <[email protected]>
-- Licensed to the public under the GNU General Public License v3.

module("luci.controller.cd8021x", package.seeall)

function index()
entry({"admin", "network", "cd8021x"}, cbi("cd8021x"), _("cd802.1x client"), 100)
entry({"admin", "network", "cd8021x"}, cbi("cd8021x"), _("cd802.1x client"), 100).dependent = true
end
14 changes: 14 additions & 0 deletions files/root/usr/lib/lua/luci/model/cbi/cd8021x.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
-- Copyright (C) 2018 max0y <[email protected]>
-- Licensed to the public under the GNU General Public License v3.

require("luci.sys")

local eap_list = {
"MD5",
"PEAP",
"MSCHAPV2",
}

m = Map("cd8021x", translate("cd802.1x client"),
translate("Configure IEEE 802.1x wired authentication, you may need to edit your WAN interface protocol as <i>DHCP client</i> <a href=\"network\">here</a>."))

Expand All @@ -19,6 +28,11 @@ for k, v in ipairs(luci.sys.net.devices()) do
end
end

eap = s:option(ListValue, "eap", translate("EAP"))
for k, v in ipairs(eap_list) do
eap:value(v)
end

local apply = luci.http.formvalue("cbi.apply")
if apply then
io.popen("/etc/init.d/cd8021x restart")
Expand Down
Binary file modified screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified screenshot_zh.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 40af235

Please sign in to comment.