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

html 播放rtsp 流rtsp2rtmp

RTSP(Real Time Streaming Protocol),RFC2326,实时流传输协议,是TCP/IP协议体系中的一个应用层协议,由哥伦比亚大学网景和RealNetworks公司提交的IETF RFC标准。该协议定义了一对多应用程序如何有效地通过IP网络传送多媒体数据。RTSP在体系结构上位于RTP和RTCP之上,它使用TCP或UDP完成数据传输。HTTP与RTSP相比,HTTP请求由客户机发出,服务器作出响应;使用RTSP时,客户机和服务器都可以发出请求,即RTSP可以是双向的。RTSP是用来控制声音或影像的多媒体串流协议,并允许同时多个串流需求控制,传输时所用的网络通讯协定并不在其定义的范围内,服务器端可以自行选择使用TCP或UDP来传送串流内容,它的语法和运作跟HTTP 1.1类似,但并不特别强调时间同步,所以比较能容忍网络延迟。而前面提到的允许同时多个串流需求控制(Multicast),除了可以降低服务器端的网络用量,更进而支持多方视讯会议(Video Conference)。因为与HTTP1.1的运作方式相似,所以代理服务器〈Proxy〉的快取功能〈Cache〉也同样适用于RTSP,并因RTSP具有重新导向功能,可视实际负载情况来转换提供服务的服务器,以避免过大的负载集中于同一服务器而造成延迟。

在旧版的chrome上可以通过vlc插件来播放rtsp视频,但是更新到新版的chrome之后要想播放这个rtsp的视频就变得比较麻烦。如果google一下就会发现有各种解决方案,但是这些方案基本都是收费的。另外一个做法就是通过ffmpeg或者vlc播放器进行协议转换,如果是单个视频流可以通过vlc进行转换,转成http协议,直接通过video标签进行播放即可。但是如果要处理的视频流比较多,那就比较麻烦了。可以通过nginx+ffmpeg进行转换。

illuspas封装了一个支持rtmp协议的nginx,https://github.com/illuspas/nginx-rtmp-win32,下载之后直接运行nginx即可启动服务。

Continue Reading