找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
广告投放联系QQ68610888
查看: 16648|回复: 35

自己写了一个花生壳公网版的luci-app-phddns

[复制链接]
发表于 2016-3-9 14:59 | 显示全部楼层 |阅读模式
本帖最后由 teasiu 于 2016-3-9 22:49 编辑

源码什么的就不献丑了,很简单的
自己用的很好。



本来不想贴代码,实在是献丑的代码,简单得很,
但是,由于引起的一些网友误会,
贴出来晒晒阳光吧。这年头,自己写几个小码也要澄清啊

  1. local sys  = require "luci.sys"
  2. if sys.call("pidof phddns >/dev/null") == 0 then
  3.         Status = "花生壳客户端 运行中"
  4. else
  5.         Status = "花生壳客户端 未运行"
  6. end
  7. m = Map("phddns")
  8. m.title        = translate("花生壳客户端")
  9. m.description = translate(Status)
  10. s = m:section(TypedSection, "phddns")
  11. s.anonymous=true
  12. s:tab("basic", translate("基本设置"))
  13. o = s:taboption("basic", Flag, "enable")
  14. o.title = translate("开启")
  15. o.rmempty = false
  16. s:taboption("basic", Value, "host", translate("服务器"))
  17. s:taboption("basic", Value, "name", translate("用户名"))
  18. s:taboption("basic", Value, "pwd", translate("密码"))
  19. nicname = s:taboption("basic",ListValue, "nicname",translate("接口"))
  20. nicname:value("", translate("选择接口"))
  21.         for _, e in ipairs(sys.net.devices()) do
  22.                 if e ~= "lo" then nicname:value(e) end
  23.         end

  24. return m
复制代码



本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

×
我的恩山、我的无线 The best wifi forum is right here.
发表于 2016-3-9 15:05 | 显示全部楼层
其实花生壳公网版的IPK已经有了,不过内网版的到是需要!

点评

内网版源码也有: controller model/cbi  详情 回复 发表于 2016-3-9 15:24
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

 楼主| 发表于 2016-3-9 15:24 | 显示全部楼层
本帖最后由 teasiu 于 2016-3-9 22:24 编辑
billking 发表于 2016-3-9 15:05
其实花生壳公网版的IPK已经有了,不过内网版的到是需要!

上图是自己写的公网版。

下面是我收集的内网版源码也有:出自潘多拉

看来这段代码引起了公愤。我再说一次,下面这段是收集的代码,我还没有欲望做内网版!
controller
  1. module("luci.controller.phddns2", package.seeall)
  2. function index()
  3.         if not nixio.fs.access("/etc/init.d/phddns2") then
  4.                 return
  5.         end
  6.         local page
  7.         page = entry({"admin", "services", "phddns2"}, form("phddns2"), _("花生壳内网版"), 40)
  8.         page.dependent = true
  9. end
复制代码

model/cbi
  1. require "luci.sys"
  2. require "luci.util"

  3. local phddns2_enabled=luci.sys.init.enabled("phddns2")

  4. m = SimpleForm("phddns2", "花生壳动态域名(内网版)", "由花生壳提供的内网穿透服务。这项服务可以将局域网内的网站直接映射到外网中,在外网通过域名访问您搭建的站点。")
  5. m.reset=false
  6. m.submit=false
  7. s = m:section(SimpleSection, "状态信息")
  8. e = s:option(Button, "endisable", " ", "启用/禁用花生壳内网版")
  9. e.render = function(self, section, scope)
  10.         if phddns2_enabled then
  11.                 self.title = translate("禁用花生壳")
  12.                 self.inputstyle = "reset"
  13.         else
  14.                 self.title = translate("启用花生壳")
  15.                 self.inputstyle = "apply"
  16.         end
  17.         Button.render(self, section, scope)
  18. end
  19. e.write = function(self, section)
  20.         if phddns2_enabled then
  21.                 phddns2_enabled=false
  22.                 luci.sys.init.stop("phddns2")
  23.                 luci.http.write("<script type="text/javascript">location.replace(location)</script>")
  24.                 luci.http.close()
  25.                 return luci.sys.init.disable("phddns2")
  26.         else
  27.                 phddns2_enabled=true
  28.                 luci.sys.init.start("phddns2")
  29.                 luci.sys.exec("sleep 2")
  30.                 luci.http.write("<script type="text/javascript">location.replace(location)</script>")
  31.                 luci.http.close()
  32.                 return luci.sys.init.enable("phddns2")
  33.         end
  34. end
  35. if (luci.sys.call("pidof oraysl > /dev/null") == 0) then
  36.         if nixio.fs.access("/tmp/oraysl.status") then
  37.                 s:option(DummyValue,"detailedstatus" ,"花生壳状态信息:", "花生壳运行中。<br />SN:" .. luci.sys.exec("head -n 2 /tmp/oraysl.status  | tail -n 1 | cut -d= -f2-") .. "<br />运行状态:" .. luci.sys.exec("head -n 3 /tmp/oraysl.status  | tail -n 1 | cut -d= -f2-"))
  38.         s:option(DummyValue,"opennewwindow" ,"<br /><p align="justify"><input type="button" class="cbi-button cbi-button-apply" value="花生棒管理页面" onclick="window.open('http://b.oray.com/')" /></p>", "使用SN登录管理页面。<br />默认密码为admin。")
  39.         else
  40.                 s:option(DummyValue,"detailedstatus" ,"花生壳状态信息:", "无法获取状态配置文件。")
  41.         end
  42. else
  43.         s:option(DummyValue,"detailedstatus" ,"花生壳状态信息:", "花生壳未运行。")
  44. end
  45. return m
复制代码



点评

亲。。。好歹注明一下出处吧。。。  发表于 2016-3-9 17:31
支持了 有IPK吗?  详情 回复 发表于 2016-3-9 15:42
支持了 有IPK吗?  详情 回复 发表于 2016-3-9 15:42
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2016-3-9 15:42 | 显示全部楼层
teasiu 发表于 2016-3-9 15:24
内网版源码也有:
controller

支持了 有IPK吗?
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2016-3-9 15:42 | 显示全部楼层
teasiu 发表于 2016-3-9 15:24
内网版源码也有:
controller

支持了 有IPK吗?
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2016-3-9 16:08 来自手机 | 显示全部楼层
有内网版的luci就好了
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2016-3-9 17:06 来自手机 | 显示全部楼层
内网版要付费的
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2016-3-9 17:08 | 显示全部楼层
看来雕兄也从无忧启动过来了~
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2016-3-9 17:29 | 显示全部楼层
公网版没必要啊?。。用自带luci-app-ddns不是可以实现么。?服务商列表里面加一行就行了。
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2016-3-9 21:55 | 显示全部楼层
这是自己写的吗

点评

公网版这个是我自己写的,大神。  详情 回复 发表于 2016-3-9 22:01
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

 楼主| 发表于 2016-3-9 22:01 | 显示全部楼层

公网版这个是我自己写的,大神。

点评

require "luci.sys" require "luci.util" local phddns2_enabled=luci.sys.init.enabled("phddns2") m = SimpleForm("phddns2", "花生壳动态域名(内网版)", "由花生壳提供的内网穿透服务。这项服务可以将局  详情 回复 发表于 2016-3-9 22:09
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2016-3-9 22:03 | 显示全部楼层
四个字:毫无必要

点评

我是从这里启发而来: http://service.oray.com/question/1890.html  详情 回复 发表于 2016-3-9 22:11
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2016-3-9 22:09 | 显示全部楼层
teasiu 发表于 2016-3-9 22:01
公网版这个是我自己写的,大神。

require "luci.sys"
require "luci.util"

local phddns2_enabled=luci.sys.init.enabled("phddns2")

m = SimpleForm("phddns2", "花生壳动态域名(内网版)", "由花生壳提供的内网穿透服务。这项服务可以将局域网内的网站直接映射到外网中,在外网通过域名访问您搭建的站点。")
m.reset=false
m.submit=false
s = m:section(SimpleSection, "状态信息")
e = sption(Button, "endisable", " ", "启用/禁用花生壳内网版")
e.render = function(self, section, scope)
    if phddns2_enabled then
        self.title = translate("禁用花生壳")
        self.inputstyle = "reset"
    else
        self.title = translate("启用花生壳")
        self.inputstyle = "apply"
    end
    Button.render(self, section, scope)
end
e.write = function(self, section)
    if phddns2_enabled then
        phddns2_enabled=false
        luci.sys.init.stop("phddns2")
        luci.http.write("<script type=\"text/javascript\">location.replace(location)</script>")
        luci.http.close()
        return luci.sys.init.disable("phddns2")
    else
        phddns2_enabled=true
        luci.sys.init.start("phddns2")
        luci.sys.exec("sleep 2")
        luci.http.write("<script type=\"text/javascript\">location.replace(location)</script>")
        luci.http.close()
        return luci.sys.init.enable("phddns2")
    end
end
if (luci.sys.call("pidof oraysl > /dev/null") == 0) then
    if nixio.fs.access("/tmp/oraysl.status") then
        sption(DummyValue,"detailedstatus" ,"花生壳状态信息:", "花生壳运行中。<br />SN:" .. luci.sys.exec("head -n 2 /tmp/oraysl.status  | tail -n 1 | cut -d= -f2-") .. "<br />运行状态:" .. luci.sys.exec("head -n 3 /tmp/oraysl.status  | tail -n 1 | cut -d= -f2-"))
    sption(DummyValue,"opennewwindow" ,"<br /><p align=\"justify\"><input type=\"button\" class=\"cbi-button cbi-button-apply\" value=\"花生棒管理页面\" onclick=\"window.open('http://b.oray.com/')\" /></p>", "使用SN登录管理页面。<br />默认密码为admin。")
    else
        sption(DummyValue,"detailedstatus" ,"花生壳状态信息:", "无法获取状态配置文件。")
    end
else
    sption(DummyValue,"detailedstatus" ,"花生壳状态信息:", "花生壳未运行。")
end
return m




这是潘多拉的内网版,你的没参考这个?

点评

内网版还没动手,只是我收集的一点代码而已。  详情 回复 发表于 2016-3-9 22:14
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

 楼主| 发表于 2016-3-9 22:11 | 显示全部楼层
hackpascal 发表于 2016-3-9 22:03
四个字:毫无必要

我是从这里启发而来:

http://service.oray.com/question/1890.html

点评

lua如此雷同  详情 回复 发表于 2016-3-9 22:14
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2016-3-9 22:14 | 显示全部楼层
teasiu 发表于 2016-3-9 22:11
我是从这里启发而来:

http://service.oray.com/question/1890.html

lua如此雷同
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

有疑问请添加管理员QQ86788181|手机版|小黑屋|Archiver|恩山无线论坛(常州市恩山计算机开发有限公司版权所有) ( 苏ICP备05084872号 )

GMT+8, 2024-4-25 06:27

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

| 江苏省互联网有害信息举报中心 举报信箱:js12377 | @jischina.com.cn 举报电话:025-88802724 本站不良内容举报信箱:68610888@qq.com 举报电话:0519-86695797

快速回复 返回顶部 返回列表