Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
mirrors
openwrt
luci
提交
b666015d
L
luci
项目概览
mirrors
/
openwrt
/
luci
11 个月 前同步成功
通知
43
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
L
luci
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
b666015d
编写于
10月 09, 2011
作者:
J
Jo-Philipp Wich
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
modules/admin-full: rework interface add dialog, now handles floating protocols like PPP correctly
上级
be71f1c9
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
50 addition
and
21 deletion
+50
-21
modules/admin-full/luasrc/model/cbi/admin_network/iface_add.lua
...s/admin-full/luasrc/model/cbi/admin_network/iface_add.lua
+50
-21
未找到文件。
modules/admin-full/luasrc/model/cbi/admin_network/iface_add.lua
浏览文件 @
b666015d
...
...
@@ -19,6 +19,8 @@ local utl = require "luci.util"
local
uci
=
require
"luci.model.uci"
.
cursor
()
m
=
SimpleForm
(
"network"
,
translate
(
"Create Interface"
))
m
.
redirect
=
luci
.
dispatcher
.
build_url
(
"admin/network/network"
)
m
.
reset
=
false
newnet
=
m
:
field
(
Value
,
"_netname"
,
translate
(
"Name of the new interface"
),
translate
(
"The allowed characters are: <code>A-Z</code>, <code>a-z</code>, "
..
...
...
@@ -29,6 +31,8 @@ newnet:depends("_attach", "")
newnet
.
default
=
arg
[
1
]
and
"net_"
..
arg
[
1
]:
gsub
(
"
[^
%w_
]
+"
,
"_"
)
newnet
.
datatype
=
"uciname"
newproto
=
m
:
field
(
ListValue
,
"_netproto"
,
translate
(
"Protocol of the new interface"
))
netbridge
=
m
:
field
(
Flag
,
"_bridge"
,
translate
(
"Create a bridge over multiple interfaces"
))
...
...
@@ -36,41 +40,66 @@ sifname = m:field(Value, "_ifname", translate("Cover the following interface"),
translate
(
"Note: If you choose an interface here which is part of another network, it will be moved into this network."
))
sifname
.
widget
=
"radio"
sifname
.
template
=
"cbi/network_ifacelist"
sifname
.
template
=
"cbi/network_ifacelist"
sifname
.
nobridges
=
true
sifname
:
depends
(
"_bridge"
,
""
)
mifname
=
m
:
field
(
Value
,
"_ifnames"
,
translate
(
"Cover the following interfaces"
),
translate
(
"Note: If you choose an interface here which is part of another network, it will be moved into this network."
))
mifname
.
widget
=
"checkbox"
mifname
.
template
=
"cbi/network_ifacelist"
mifname
.
template
=
"cbi/network_ifacelist"
mifname
.
nobridges
=
true
mifname
:
depends
(
"_bridge"
,
"1"
)
function
newnet
.
write
(
self
,
section
,
value
)
local
bridge
=
netbridge
:
formvalue
(
section
)
==
"1"
local
ifaces
=
bridge
and
mifname
:
formvalue
(
section
)
or
sifname
:
formvalue
(
section
)
local
nn
=
nw
:
add_network
(
value
,
{
proto
=
"none"
})
if
nn
then
if
bridge
then
nn
:
set
(
"type"
,
"bridge"
)
local
_
,
p
for
_
,
p
in
ipairs
(
nw
:
get_protocols
())
do
if
p
:
is_installed
()
then
newproto
:
value
(
p
:
proto
(),
p
:
get_i18n
())
if
not
p
:
is_virtual
()
then
netbridge
:
depends
(
"_netproto"
,
p
:
proto
())
end
if
not
p
:
is_floating
()
then
sifname
:
depends
({
_bridge
=
""
,
_netproto
=
p
:
proto
()})
mifname
:
depends
({
_bridge
=
"1"
,
_netproto
=
p
:
proto
()})
end
end
end
local
iface
for
iface
in
utl
.
imatch
(
ifaces
)
do
nn
:
add_interface
(
iface
)
if
not
bridge
then
break
end
end
function
newproto
.
validate
(
self
,
value
,
section
)
local
name
=
newnet
:
formvalue
(
section
)
if
not
name
or
#
name
==
0
then
newnet
:
add_error
(
section
,
translate
(
"No network name specified"
))
elseif
m
:
get
(
name
)
then
newnet
:
add_error
(
section
,
translate
(
"The given network name is not unique"
))
end
nw
:
save
(
"network"
)
nw
:
save
(
"wireless"
)
local
proto
=
nw
:
get_protocol
(
value
)
if
proto
and
not
proto
:
is_floating
()
then
local
br
=
(
netbridge
:
formvalue
(
section
)
==
"1"
)
local
ifn
=
br
and
mifname
:
formvalue
(
section
)
or
sifname
:
formvalue
(
section
)
for
ifn
in
utl
.
imatch
(
ifn
)
do
return
value
end
return
nil
,
translate
(
"The selected protocol needs a device assigned"
)
end
return
value
end
luci
.
http
.
redirect
(
luci
.
dispatcher
.
build_url
(
"admin/network/network"
,
nn
:
name
()))
function
newproto
.
write
(
self
,
section
,
value
)
local
name
=
newnet
:
formvalue
(
section
)
if
name
and
#
name
>
0
then
local
br
=
(
netbridge
:
formvalue
(
section
)
==
"1"
)
and
"bridge"
or
nil
local
net
=
nw
:
add_network
(
name
,
{
proto
=
value
,
type
=
br
})
if
net
then
local
ifn
for
ifn
in
utl
.
imatch
(
br
and
mifname
:
formvalue
(
section
)
or
sifname
:
formvalue
(
section
)
)
do
net
:
add_interface
(
ifn
)
end
nw
:
save
(
"network"
)
nw
:
save
(
"wireless"
)
end
luci
.
http
.
redirect
(
luci
.
dispatcher
.
build_url
(
"admin/network/network"
,
name
))
end
end
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录