愿星光伴随你左右


  • 首页

  • todo

  • 思考

  • life

  • food

  • OS

  • lua

  • redis

  • Golang

  • C

  • TCP/IP

  • ebpf

  • p4

  • OpenVPN

  • IPSec

  • L2TP

  • DNS

  • distributed

  • web

  • OpenWRT

  • 运维

  • Git

  • 鸟哥的私房菜

  • IT杂谈

  • 投资

  • About Me

  • 友情链接

  • FTP

  • 搜索
close

Openwrt LuCI CBI(二)

时间: 2022-10-21   |   分类: OpenWrt     |   阅读: 4392 字 ~9分钟

一、CBI控件类型汇总

  • CBI模型是描述UCI配置文件结构的Lua文件,并且CBI解析器将lua文件转为HTML呈现给用户 。
  • 所有 CBI 模型文件必须返回类型为 luci.cbi.Map 的对象。
  • CBI 模型文件的范围由 luci.cbi 模块的内容和 luci.i18n 的转换函数自动扩展。
名称 描述 继承自 模板
NamedSection A fixed configuration section defined by its name NamedSection = class(AbstractSection) cbi/nsection
TypedSection A (set of) configuration section(s) defined by the type TypedSection = class(AbstractSection) cbi/tsection
Node Node pseudo abstract class Node = class() cbi/node
Template A simple template element Template = class(Node)
Map A map describing a configuration file Map = class(Node) cbi/map
Compound Container Compound = class(Node) cbi/compound
Delegator Node controller Delegator = class(Node) cbi/delegator
SimpleForm A Simple non-UCI form SimpleForm = class(Node) cbi/simpleform
Form Form = class(SimpleForm)
AbstractSection AbstractSection = class(Node)
SimpleSection SimpleSection = class(AbstractSection) cbi/nullsection
Table Table = class(AbstractSection) cbi/tblsection
AbstractValue An abstract Value Type AbstractValue = class(Node)
Value A one-line value Value = class(AbstractValue) cbi/value
DummyValue This does nothing except being there DummyValue = class(AbstractValue) cbi/dvalue
Flag A flag being enabled or disabled Flag = class(AbstractValue) cbi/fvalue
ListValue A one-line value predefined in a list ListValue = class(AbstractValue) cbi/lvalue
MultiValue Multiple delimited values MultiValue = class(AbstractValue) cbi/mvalue
StaticList StaticList = class(MultiValue)
DynamicList DynamicList = class(AbstractValue) cbi/dynlist
TextValue A multi-line value TextValue = class(AbstractValue) cbi/tvalue
Button Button = class(AbstractValue) cbi/button
FileUpload FileUpload = class(AbstractValue) cbi/upload
FileBrowser FileBrowser = class(AbstractValue) cbi/browser
Page A simple node Page = class(Node)

二、CBI常用控件用法详解

2.1 class Map (config, title, description)

  • This is the root object of the model.。
  • 模型的根对象

参数说明:

阅读全文 »

Pushing a branch to Bitbucket fails with the error, "refspec matches more than one".

时间: 2022-10-21   |   分类: git     |   阅读: 414 字 ~2分钟

Summary

The error “refspec matches more than one” is shown while pushing a branch to Bitbucket.

This occurs because there is more than one Git ref that matches the ref name specified in the push command.

Example

Suppose a repo has a branch and a tag with the same name, “dev”.

When an attempt is made to push the “dev” branch to the remote, the error “refspec matches more than one” will be shown and the push fails.

阅读全文 »

Openwrt LuCI 入门(一)

时间: 2022-10-20   |   分类: OpenWrt     |   阅读: 3872 字 ~8分钟

LuCI基本概念

  • UCI 是 Openwrt 中为实现所有系统配置的一个统一接口,英文名 Unified Configuration Interface,即统一配置接口。轻量级 LUA 语言的官方版本只包括一个精简的核心和最基本的库。这使得 LUA 体积小、启动速度快,从而适合嵌入在别的程序里。 LuCI 即是这两个项目的合体,可以实现路由的网页配置界面。

阅读全文 »

OpenWrt netifd学习笔记

时间: 2022-10-20   |   分类: OpenWrt     |   阅读: 4737 字 ~10分钟

Netifd简介

Netifd是OpenWrt中用于进行网络配置的守护进程,基本上所有网络接口设置以及内核的netlink事件都可以由netifd来处理完成。 在启动netifd之前用户需要将所需的配置写入uci配置文件/etc/config/network中,以告知netifd如何设置这些网络接口,如IP地址、上网类型等。如果在netifd运行过程中需要修改配置,则只需更新并保存/etc/config/network,执行/etc/init.d/network reload,netifd便可根据配置文件差异快速地完成网络接口的更新。

阅读全文 »

Openwrt ubus实现进程间通信举例

时间: 2022-10-20   |   分类: OpenWrt     |   阅读: 3994 字 ~8分钟

上一篇文章介绍了ubus的组件和实现原理,本文通过代码实例介绍使用ubus进行进程间通信的三种方式。

  1. invoke的方式实现端对端通信 最简单的情景就是一个提供服务的server端,一个请求服务的client端,client请求server的服务。 下面的例子中,server注册了一个名为“scan_prog”的对象,该对象中提供一个“scan”方法: ubus_invoke.h:
#ifndef __UBUS_INVOKE_H__
#define __UBUS_INVOKE_H__
#include <json/json.h>
#include <libubox/blobmsg_json.h>
 
 
struct prog_attr {
	char name[64];
	int chn_id;
};
#define PROG_MAX	8
 
 
#endif  /* __UBUS_INVOKE_H__ */

invoke_server.c:

阅读全文 »

OpenWrt 使用 ubus实现进程通信

时间: 2022-10-20   |   分类: OpenWrt     |   阅读: 3627 字 ~8分钟

ubus为openwrt平台开发中的进程间通信提供了一个通用的框架。它让进程间通信的实现变得非常简单,并且ubus具有很强的可移植性,可以很方便的移植到其他linux平台上使用。本文描述了ubus的实现原理和整体框架。

阅读全文 »

JSON-RPC

时间: 2022-10-20   |   分类: web     |   阅读: 1047 字 ~3分钟

JSON-RPC

From Wikipedia, the free encyclopedia

Jump to navigationJump to search

JSON-RPC is a remote procedure call protocol encoded in JSON. It is similar to the XML-RPC protocol, defining only a few data types and commands. JSON-RPC allows for notifications (data sent to the server that does not require a response) and for multiple calls to be sent to the server which may be answered asynchronously.

Version Description Dated
1.0 Original version 2005
1.1 WD Working draft. Adds named parameters, adds specific error codes, and adds introspection functions. 2006-08-07
1.1 Alt Suggestion for a simple JSON-RPC 1.1. Alternative proposal to 1.1 WD. 2007-05-06
1.1 Object Specification Object Specification. Alternative proposal to 1.1 WD/1.1ALT. 2007-07-30
1.2 Proposal. A later revision of this document was renamed to 2.0. 2007-12-27
2.0 Specification proposal 2009-05-24
2.0 (Revised-) Specification 2010-03-26

Usage

JSON-RPC works by sending a request to a server implementing this protocol. The client in that case is typically software intending to call a single method of a remote system. Multiple input parameters can be passed to the remote method as an array or object, whereas the method itself can return multiple output data as well. (This depends on the implemented version.)

阅读全文 »

lua常用函数-打印表

时间: 2022-10-19   |   分类: lua     |   阅读: 74 字 ~1分钟
  • 打印表
function PrintTable(table, key, level)
  level = level or 1
  local indent = ""
  for i = 1, level do
    indent = indent.."  "
  end

  if key ~= nil then
    print(indent..key.." ".."=".." ".."{")
  else
    print(indent .. "{")
  end

  for k,v in pairs(table) do
     if type(v) == "table" then
        PrintTable(v, key, level + 1)
     else
        local content = string.format("%s%s = %s", indent .. "  ",tostring(k), tostring(v))
      print(content)  
      end
  end
  print(indent .. "}")
end
25 26 27 28 29 30 31 32 33

日志
分类
标签
RSS 订阅
GitHub
© 2009 - 2025
粤ICP备2021068940号-1 粤公网安备44011302003059
0%