mosquitto not authorised

Eclipse Mosquitto is an open source (EPL/EDL licensed) message broker that implements the MQTT protocol versions 5.0, 3.1.1 and 3.1. Mosquitto is lightweight and is suitable for use on all devices from low power single board computers to full servers.
The MQTT protocol provides a lightweight method of carrying out messaging using a publish/subscribe model. This makes it suitable for Internet of Things messaging such as with low power sensors or mobile devices such as phones, embedded computers or microcontrollers.
The Mosquitto project also provides a C library for implementing MQTT clients, and the very popular mosquitto_pub and mosquitto_sub command line MQTT clients.

最近需要用mqtt来实现消息处理,在windows上安装Mosquitto之后,不使用用户名密码提示connection refused: not authorised。结果添加用户名密码之后还是提示同样的错误。

Continue Reading

Django 代码保护

常用的代码保护不外乎下面几种方法:

发行 .pyc 文件
代码混淆
使用 py2exe
使用 Cython

django发布的需要以服务运行,通过其他的几种方法来实现保护,都不太现实。所以发布可以通过cython的方式实现。

1. 安装cython

pip3 install cython

2.在项目目录创建setup.py 编辑内容如下,其中“app/file1.py”是你所要打包的py文件名,这儿需要把app下所有的py文件都添加进来(当然也可以添加部分)

from distutils.core import setup

from Cython.Build import cythonize

fileSet = set()

fileSet.add("UserBase/models.py")
fileSet.add("UserBase/views.py")

setup(

    ext_modules=cythonize(fileSet)

)

Continue Reading

Freeswitch sip Push notifications

不管是安卓还是ios现在多数的app都无法长时间在后台运行(特殊权限以及应用除外),如果要想在app没有激活或者被冻结的情况下接收到来电,那么就需要先推送一条通知。

搜了一下有这么个插件:https://github.com/sem32/freeswitch-PushNotificator 尝试了一下发现编译起来比较麻烦,后来发现了这篇文章:https://www.zoiper.com/en/tutorials/push-notifications参考里面的关键代码,包含一个push.sh,代码如下:

Continue Reading

基于Freeswitch的语音视频通话

之前写过一篇《阿里云 opensips nat内网穿透》,当时是为了解决对讲机视频对讲的问题。但是之前的方案存在一个问题,那就是虽然服务器能够正常提供服务。但是在接通之后如果设备不在同一个局域网内就会导致有音频但是没有视频信息。这个问题困扰了很久,直到现在算是能够解决这个问题。出现上面这个问题的根本原因在于设备的网络层次关系太过复杂,视频信息没有办法透传。我不是语音视频方面的专家,集中nat结构我也不在叙述了,感兴趣的访问这个链接:https://www.cnblogs.com/zhumengke/articles/11204924.html

如果要在阿里云的服务器上,还需要升级绑定弹性网卡的相关内容,具体参考这里:https://developer.aliyun.com/article/228753?spm=a2c6h.13813017.content3.1.5cbc6532wDqNf4

Continue Reading

nginx 代理google搜索

为了能够正常访问google进行搜索,之前一直用的ssh转socks代理。后来觉得如果s2主机只用来做代理,有点浪费了。于是就想了干脆反向代理一个google搜索。网上相关的文章比较多,随便搜索一下就可以找到相关的代码。基于nginx的主要配置代码如下:

proxy_cache_path /tmp/accounts levels=1:2 keys_zone=cache:10m max_size=10g inactive=60m use_temp_path=off;
server {
        server_name h4ck.ws;
        location / {
      proxy_redirect off;
      proxy_cache cache;
      proxy_cache_valid   200 304 12h;
      proxy_cache_valid   any 10m;
      proxy_cookie_domain google.com h4ck.ws;
      proxy_pass https://www.google.com;
      proxy_connect_timeout 20s;
      proxy_read_timeout 600s;
      proxy_send_timeout 600s;

      proxy_set_header Host "www.google.com";
      proxy_set_header User-Agent $http_user_agent;
      proxy_set_header Referer https://www.google.com;
      proxy_set_header Accept-Encoding "";
      proxy_set_header X-Real-IP $remote_addr;
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header X-Forwarded-Proto https;
      proxy_set_header Accept-Language "zh-CN";
#     proxy_set_header Cookie "PREF=ID=047808f19f6de346:U=0f62f33dd8549d11:FF=2:LD=zh-CN:NW=1:TM=1325338577:LM=1332142444:GM=1:SG=2:S=rE0SyJh2W1IQ-Maw"; #这行代码可能会导致google监测到流量异常
      sub_filter https://www.google.com https://h4ck.ws;
      sub_filter https://www.google.co.jp https://h4ck.ws;
      sub_filter_once off;
      addition_types *;
  }
}
Continue Reading