cfadmin-cn / cfadmin Goto Github PK
View Code? Open in Web Editor NEWA lua web network framework.
Home Page: https://cfadmin.cn
License: BSD 3-Clause "New" or "Revised" License
A lua web network framework.
Home Page: https://cfadmin.cn
License: BSD 3-Clause "New" or "Revised" License
hi
较之前的处理 require 需要携带script 而言,现在方式存在重名加载的问题。主要开发都在script目录,需要约束知道lualib 有哪些库。之前不存在这个问题,更为合理。比如增加 mail.lua,路由配置require(“mail”);http 返回405 错误的。
BR
hi,
how to config https support ?
nice
Hi,CandyMi
html template support embed html like follow
{(static/Name.html)}
but can not support Name from lua script
{(static/{*Name*}.html)}
类似muduo和其他几个开源库的比较
Hi,
where can i find example about file upload for the cf framework
thanks
core.c:204:2: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
core.c:204:2: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
core.c:204:2: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
/usr/bin/ld: /usr/local/lib/liblua.a(lstate.o): relocation R_X86_64_PC32 against symbol `lua_newstate' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: 最后的链结失败: 错误的值
collect2: error: ld returned 1 exit status
Makefile:32: recipe for target 'build' failed
make: *** [build] Error 1
不知道如何解决呢
if my url is image has special character, the image in static path will load fail
lualib/protocol/http.lua
PATH = UrlDecode(PATH)
local cls, typ = ROUTE_FIND(METHOD, PATH)
hi
经过使用,发现对客户端信息缺失地址和端口。建议默认提供接口查询本次消息,谁发来的;或者加入消息中。
使用场景:
1. 安全机制,非法访问的来源,加入黑名单
2. 物联网,根据客户端ip 端口,映射设备身份,不需要额外增加应用层消息。
何况libuv有node.js这样的流行的框架在用, 性能和稳定性更有保障.
Hi, CandyMi
the Httpc can not fetch from many web support User-Agent check, or Accept-Encoding compress
"User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_0) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.56 Safari/535.11\r\n"
Accept-Encoding: gzip,deflate
hi
测试过程中发现几个问题:
@ubuntu:~/cdcore/core_framework$ make rebuild
********** Core library and executable **********
CC - libcore
CC - cfadmin
/usr/bin/ld: ./libcore.so: undefined reference to sinh' /usr/bin/ld: ./libcore.so: undefined reference to
log2'
/usr/bin/ld: ./libcore.so: undefined reference to atan2' /usr/bin/ld: ./libcore.so: undefined reference to
tanh'
/usr/bin/ld: ./libcore.so: undefined reference to cosh' /usr/bin/ld: ./libcore.so: undefined reference to
fmod'
/usr/bin/ld: ./libcore.so: undefined reference to acos' /usr/bin/ld: ./libcore.so: undefined reference to
sin'
/usr/bin/ld: ./libcore.so: undefined reference to asin' /usr/bin/ld: ./libcore.so: undefined reference to
exp'
/usr/bin/ld: ./libcore.so: undefined reference to tan' /usr/bin/ld: ./libcore.so: undefined reference to
cos'
/usr/bin/ld: ./libcore.so: undefined reference to log' /usr/bin/ld: ./libcore.so: undefined reference to
pow'
/usr/bin/ld: ./libcore.so: undefined reference to log10' /usr/bin/ld: ./libcore.so: undefined reference to
sqrt'
collect2: error: ld returned 1 exit status
make[1]: *** [Makefile:36:build] 错误 1
make: *** [Makefile:24:rebuild] 错误 2
请求大神 编译错误。
hi
去年的版本,使用正常,从github上下载,重新编译安装后,发现mysql连接不上,回退正常。再次安装还是不行。
后来修改main.lua mysql 连接localhost为127.0.0.1 ok。
最新代码应该有调整dns相关的处理,导致不能兼容。
使用admin 登录;chrome下没任何问题;
换成firefox,登录成功后又返回登录界面,死循环。
抓包看了一下,firefox在登录成功后的admin/dashbord 请求中cookie 只有CFLANG,没有CFTOKEN
换了几个firefox版本均是如此。
很多管理系统,数据需要隔离,有了个账套的概念。
比如 AB 两个应用,分别需要管理员admin@A admin@B;如果用admin的鉴权 ,登录后下一次访问无法知道是哪个库的。
cookie加字段是可以的,这样每次处理是根据cookie 找数据库。 如果浏览器禁用cookie 怎么办?
是否有更好的方法实现?
`# -- coding=utf8 --
from cryptography.hazmat.primitives.ciphers.aead import AESGCM
import hashlib,,cryptography.exceptions
import base64
def decrypt(key,nonce, ciphertext, associated_data):
print(key,nonce, ciphertext, associated_data)
key_bytes = str.encode(key)
nonce_bytes = str.encode(nonce)
ad_bytes = str.encode(associated_data)
data = base64.b64decode(ciphertext)
aesgcm = AESGCM(key_bytes)
ret_str = aesgcm.decrypt(nonce_bytes, data, ad_bytes)
print(ret_str)
def encrypt(key,nonce, ciphertext, associated_data):
print(key,nonce, ciphertext, associated_data)
key_bytes = str.encode(key)
nonce_bytes = str.encode(nonce)
ad_bytes = str.encode(associated_data)
aesgcm = AESGCM(key_bytes)
ret_str = aesgcm.encrypt(nonce_bytes, ciphertext, ad_bytes)
print(base64.b64encode(ret_str))#加密后未将ad_bytes拼接,有些加密函数会拼接起来
if name == 'main':
if sys.argv[1]=="en":
encrypt(sys.argv[2],sys.argv[3],sys.argv[4],sys.argv[5])
elif sys.argv[1]=="de":
decrypt(sys.argv[2],sys.argv[3],sys.argv[4],sys.argv[5])
`
这是python加解密的代码
这是数据
明文
THIS_IS_SUCCESS_DATA
key
jysng121054180907654321741852963
随机字符串
qKJB3l8rkNEF
aad(附加数据包)
test_aad
加密
python aead_aes_256_gcm.py en jysng121054180907654321741852963 qKJB3l8rkNEF THIS_IS_SUCCESS_DATA test_aad
解密
python aead_aes_256_gcm.py de jysng121054180907654321741852963 qKJB3l8rkNEF PD4m3fac6rXLqEspUpR9Sv/3S+F/4e/fHWssMz8SY9EIJ6Mo test_aad
可以用你的库么...
cfadmin的设计思路中,似乎是推荐使用rpc的风格设计接口。
但是也必然存在需要设计restful风格接口的场景,(比如公司项目规范规定)
我寻思应该增加DELETE和PATCH动词的支持,以支持此类需求
Hi, CandyMi
what is the default way that handle image cache in core framework, the png number over 10 will cause so slow to replay, if use the thirty cache, how to integrate ?
hi,
I want to make a spider use cf like follow code, it can work well both https/http protocol
local hc = http:new {}
local code, body = hc:get(Url)
print(code, body)
the problem is how to support multi thread ?
有文件上传的例子吗
hi,
主干上最新的代码启动 不能兼容之前的参数,-d需要创建logs 目录才支持-d参数,会大量的打印。 和之前提到localhost一样不能兼容。
ubutun 18
文档说依赖libev 和lua 5.3 不够全面。必须依赖mysql,没有mysql 不能运行。
是否可以考虑多数据库支持?luasql 这样的。
2 .git 下载后编译,编译有错误:
1). lua 不能正确连接 math库
2). 路径一定在usr /local.. 下找,非root用户有些麻烦,交叉编译不行。
3). 没安装打包。
运行时总是连接mysql 出问题。几分钟就近1G日志。手动连接mysql,都没有问题。
更换docker
运行:docker-compose -f docker-compose-with-cfadmin.yaml up
出现两种错误:
1) mysql 冲突,这个停掉主机mysql 可以暂时解决
2) 同样一直连接mysql。 日志如下:
root@testu:/mnt/work/core_framework/docker# docker-compose -f docker-compose-with-cfadmin.yaml up
Starting docker_WebDB_1 ...
Starting docker_WebDB_1 ... done
Starting docker_WebApp_1 ...
Starting docker_WebApp_1 ... done
Attaching to docker_WebDB_1, docker_WebApp_1
WebDB_1 | 2020-07-15 06:06:53+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 5.6.49-1debian9 started.
WebDB_1 | 2020-07-15 06:06:54+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
WebDB_1 | 2020-07-15 06:06:54+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 5.6.49-1debian9 started.
WebDB_1 | 2020-07-15 06:06:55 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
WebDB_1 | 2020-07-15 06:06:56 0 [Note] mysqld (mysqld 5.6.49) starting as process 1 ...
WebDB_1 | 2020-07-15 06:06:56 1 [Note] Plugin 'FEDERATED' is disabled.
WebDB_1 | 2020-07-15 06:06:56 1 [Note] InnoDB: Using atomics to ref count buffer pool pages
WebDB_1 | 2020-07-15 06:06:56 1 [Note] InnoDB: The InnoDB memory heap is disabled
WebDB_1 | 2020-07-15 06:06:56 1 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
WebDB_1 | 2020-07-15 06:06:56 1 [Note] InnoDB: Memory barrier is not used
WebDB_1 | 2020-07-15 06:06:56 1 [Note] InnoDB: Compressed tables use zlib 1.2.11
WebDB_1 | 2020-07-15 06:06:56 1 [Note] InnoDB: Using Linux native AIO
WebDB_1 | 2020-07-15 06:06:56 1 [Note] InnoDB: Using CPU crc32 instructions
WebDB_1 | 2020-07-15 06:06:56 1 [Note] InnoDB: Initializing buffer pool, size = 128.0M
WebDB_1 | 2020-07-15 06:06:56 1 [Note] InnoDB: Completed initialization of buffer pool
WebDB_1 | 2020-07-15 06:06:56 1 [Note] InnoDB: Highest supported file format is Barracuda.
WebDB_1 | 2020-07-15 06:06:56 1 [Note] InnoDB: The log sequence numbers 1625987 and 1625987 in ibdata files do not match the log sequence number 1625997 in the ib_logfiles!
WebDB_1 | 2020-07-15 06:06:56 1 [Note] InnoDB: Database was not shutdown normally!
WebDB_1 | 2020-07-15 06:06:56 1 [Note] InnoDB: Starting crash recovery.
WebDB_1 | 2020-07-15 06:06:56 1 [Note] InnoDB: Reading tablespace information from the .ibd files...
WebDB_1 | 2020-07-15 06:06:56 1 [ERROR] InnoDB: space header page consists of zero bytes in tablespace ./cfadmin/cfadmin_headers.ibd (table cfadmin/cfadmin_headers)
WebDB_1 | 2020-07-15 06:06:56 1 [Note] InnoDB: Page size:1024 Pages to analyze:64
WebDB_1 | 2020-07-15 06:06:56 1 [Note] InnoDB: Page size: 1024, Possible space_id count:0
WebDB_1 | 2020-07-15 06:06:56 1 [Note] InnoDB: Page size:2048 Pages to analyze:32
WebDB_1 | 2020-07-15 06:06:56 1 [Note] InnoDB: Page size: 2048, Possible space_id count:0
WebDB_1 | 2020-07-15 06:06:56 1 [Note] InnoDB: Page size:4096 Pages to analyze:16
WebDB_1 | 2020-07-15 06:06:56 1 [Note] InnoDB: Page size: 4096, Possible space_id count:0
WebDB_1 | 2020-07-15 06:06:56 1 [Note] InnoDB: Page size:8192 Pages to analyze:8
WebDB_1 | 2020-07-15 06:06:56 1 [Note] InnoDB: Page size: 8192, Possible space_id count:0
WebDB_1 | 2020-07-15 06:06:56 1 [Note] InnoDB: Page size:16384 Pages to analyze:4
WebDB_1 | 2020-07-15 06:06:56 1 [Note] InnoDB: Page size: 16384, Possible space_id count:0
WebDB_1 | 2020-07-15 06:06:56 7fdd85f79040 InnoDB: Operating system error number 2 in a file operation.
WebDB_1 | InnoDB: The error means the system cannot find the path specified.
WebDB_1 | InnoDB: If you are installing InnoDB, remember that you must create
WebDB_1 | InnoDB: directories yourself, InnoDB does not create them.
WebDB_1 | InnoDB: Error: could not open single-table tablespace file ./cfadmin/cfadmin_headers.ibd
WebDB_1 | InnoDB: We do not continue the crash recovery, because the table may become
WebDB_1 | InnoDB: corrupt if we cannot apply the log records in the InnoDB log to it.
WebDB_1 | InnoDB: To fix the problem and start mysqld:
WebDB_1 | InnoDB: 1) If there is a permission problem in the file and mysqld cannot
WebDB_1 | InnoDB: open the file, you should modify the permissions.
WebDB_1 | InnoDB: 2) If the table is not needed, or you can restore it from a backup,
WebDB_1 | InnoDB: then you can remove the .ibd file, and InnoDB will do a normal
WebDB_1 | InnoDB: crash recovery and ignore that table.
WebDB_1 | InnoDB: 3) If the file system or the disk is broken, and you cannot remove
WebDB_1 | InnoDB: the .ibd file, you can set innodb_force_recovery > 0 in my.cnf
hi
设备一直运行,大约30台,发现有1-2台设备页面连不上,查询进程死掉了。
查看日志,没报错误,具体原因尚不明确。 手动拉起来,跟踪,发现有的啥也不操作也会退出进程。
由于随机性的,很难确定,也很难发现,但由于设备多,出现了几次,才确认有这个问题。
估计短期无法定位,暂时外部加了watchdog,定时扫描程序健康检查。不由得想起之前提的问题,popen 信号屏蔽及多进程的,建议一个方案:
可选启动管理进程,管理进程做watchdog,根据参数 检查健康,检查网络,检查dns;负责执行popen,system 命令。
子进程处理http 消息,如果后台执行系统命令 提供执行系统命令接口【发送消息给管理进程去执行(如果没有管理进程,保持原样)】;
这样 所有问题基本都解决了,而且起到意外或其他情况导致程序挂掉,迅速拉起来。
BR
hi
后台调用脚本启动程序 无法kill 经定位发现屏蔽了信号量。
之前代码 是ok的。
BR
hi
简而言之,Content-Type 应该提供接口修改。
因为:
1) rest 打开全部放过后(/{string[]:slist}),static就不会再生效了,需要自己去读取文件,读出内容返回 类型不能正确。
2) 即使不用rest,需要读取的文件,可能httpc 或mq 等方式读取,必须不能进入static处理,这时类型也不能保证正确。
为了实现这个目的,尝试了一种办法,也就是上一个问题——起两个实例的问题。既然不能使用两个实例,只能启用两个进程来处理,A B进程,A 收到请求,获取到数据,写文件到静态路径下,回响应给浏览器redirect(B),浏览器发起B请求,从静态文件下获取。 确实可以实现,但很麻烦,如果浏览器稍微严格一点,不同端口算跨域也就不行了。最好方法是可以修改Content-Type。
当然如果能 解决精确匹配路由和模糊匹配路由及staic的优先级,重定向也是一种办法。
文件上传10M 文件 就不能上传了,负载等于1024*1024 也是不行的。
sudo docker-compose -f docker-compose-with-cfadmin.yaml up
Removing docker_WebDB_1
Recreating 83fbed6029b8_docker_WebDB_1 ...
ERROR: for 83fbed6029b8_docker_WebDB_1 a bytes-like object is required, not 'str'
ERROR: for WebDB a bytes-like object is required, not 'str'
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/docker/api/client.py", line 261, in _raise_for_status
response.raise_for_status()
File "/usr/lib/python3/dist-packages/requests/models.py", line 940, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 500 Server Error: Internal Server Error for url: http+docker://localhost/v1.22/containers/cdc1bfccb594fce8c8fae0d578a88a54fb3aba2b477bc84e56f8fcb2c37e81a8/start
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/compose/service.py", line 625, in start_container
container.start()
File "/usr/lib/python3/dist-packages/compose/container.py", line 241, in start
return self.client.start(self.id, **options)
File "/usr/lib/python3/dist-packages/docker/utils/decorators.py", line 19, in wrapped
return f(self, resource_id, *args, **kwargs)
File "/usr/lib/python3/dist-packages/docker/api/container.py", line 1095, in start
self._raise_for_status(res)
File "/usr/lib/python3/dist-packages/docker/api/client.py", line 263, in _raise_for_status
raise create_api_error_from_http_exception(e)
File "/usr/lib/python3/dist-packages/docker/errors.py", line 31, in create_api_error_from_http_exception
raise cls(e, response=response, explanation=explanation)
docker.errors.APIError: 500 Server Error: Internal Server Error ("b'driver failed programming external connectivity on endpoint docker_WebDB_1 (6c74d89f66aabbe75f58589e459f17ced5c13ea5b049b631340d4c12cf021a36): Error starting userland proxy: listen tcp 0.0.0.0:3306: bind: address already in use'")
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/bin/docker-compose", line 11, in
load_entry_point('docker-compose==1.25.0', 'console_scripts', 'docker-compose')()
File "/usr/lib/python3/dist-packages/compose/cli/main.py", line 72, in main
command()
File "/usr/lib/python3/dist-packages/compose/cli/main.py", line 128, in perform_command
handler(command, command_options)
File "/usr/lib/python3/dist-packages/compose/cli/main.py", line 1107, in up
to_attach = up(False)
File "/usr/lib/python3/dist-packages/compose/cli/main.py", line 1088, in up
return self.project.up(
File "/usr/lib/python3/dist-packages/compose/project.py", line 565, in up
results, errors = parallel.parallel_execute(
File "/usr/lib/python3/dist-packages/compose/parallel.py", line 112, in parallel_execute
raise error_to_reraise
File "/usr/lib/python3/dist-packages/compose/parallel.py", line 210, in producer
result = func(obj)
File "/usr/lib/python3/dist-packages/compose/project.py", line 548, in do
return service.execute_convergence_plan(
File "/usr/lib/python3/dist-packages/compose/service.py", line 561, in execute_convergence_plan
return self._execute_convergence_recreate(
File "/usr/lib/python3/dist-packages/compose/service.py", line 486, in _execute_convergence_recreate
containers, errors = parallel_execute(
File "/usr/lib/python3/dist-packages/compose/parallel.py", line 112, in parallel_execute
raise error_to_reraise
File "/usr/lib/python3/dist-packages/compose/parallel.py", line 210, in producer
result = func(obj)
File "/usr/lib/python3/dist-packages/compose/service.py", line 481, in recreate
return self.recreate_container(
File "/usr/lib/python3/dist-packages/compose/service.py", line 602, in recreate_container
self.start_container(new_container)
File "/usr/lib/python3/dist-packages/compose/service.py", line 627, in start_container
if "driver failed programming external connectivity" in ex.explanation:
TypeError: a bytes-like object is required, not 'str'
第一次发现这个 但是运行不了 不知道那里的问题 希望大神提点一下 谢谢啦
hi
之前提到过的一个老问题,popen 阻塞时,导致整个程序都阻住了,其他访问都不能进行,直到popen执行结束才能恢复。
下面为测试代码,如果将fork 里执行换掉popen直接用cf.sleep 就可以。这是什么原因,对于执行时间过久的 怎么才能让出线程,让其他访问继续呢?
app:use('/get',function(ctx, db)
local res
local co=cf.self()
cf.fork(function()
local secondfile = io.popen([[sleep 10;echo "1234"]])
res = secondfile:read("*a")
secondfile:close()
cf.wakeup(co,res)
end)
cf.wait()
print("res",res)
return res
end)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.