Install DNSCrypt in PFSense 2.4

How to install other FreeBSD packages / repositories?
1. Make sure “enabled” key is set to “yes” in /etc/pkg/FreeBSD.conf
2. Change “enabled: no” to “enabled: yes” in /usr/local/etc/pkg/repos/FreeBSD.conf
3. Change “enabled: no” to “enabled: yes” in /usr/local/etc/pkg/repos/pfSense.conf for FreeBSD repo
4. Now you’re able to install packages from FreeBSD official repo

pkg install nano wget vim
pkg install dnscrypt-proxy

http://dnsrec.meo.ws/

/usr/local/sbin/dnscrypt-proxy –user=_dnscrypt-proxy –local-address=127.0.0.1:54 –pidfile=/var/run/dnscrypt-proxy.pid –resolver-address=185.121.177.177:5353 –provider-name=2.dnscrypt-cert.dnsrec.meo.ws –provider-key=1A6A:D0A3:2B4C:5A61:A695:D153:670D:69AB:1690:3F9E:C3F7:F64F:13E5:35A3:18B2:28A5

[NOTICE] Starting dnscrypt-proxy 1.9.5
[INFO] Generating a new session key pair
[INFO] Done
[INFO] Server certificate with serial #1496061161 received
[INFO] This certificate is valid
[INFO] Chosen certificate #1496061161 is valid from [2017-05-29] to [2027-05-27]
[INFO] The key rotation period for this server may exceed the recommended value. This is bad for forward secrecy.
[INFO] Server key fingerprint is E737:6400:D646:0720:7D9D:29AB:A4C9:070C:4546:CEF7:0CFE:D62F:41E9:FEAA:C58F:6376
[NOTICE] Proxying from 127.0.0.1:54 to 185.121.177.177:5353

dig -4 @127.0.0.1 -p 54 slashdot.org

Custom options
local=/home/
cache-size=16384
log-async=5
addn-hosts=/var/etc/dnsmasq/hosts
server=127.0.0.1#54
server=127.0.0.1#55

/usr/local/sbin/dnscrypt-proxy -d –user=_dnscrypt-proxy \
–local-address=127.0.0.1:55 \
–pidfile=/var/run/dnscrypt-proxy2.pid \
–resolver-address=169.239.202.202:5353 \
–provider-name=2.dnscrypt-cert.dnsrec.meo.ws \
–provider-key=1A6A:D0A3:2B4C:5A61:A695:D153:670D:69AB:1690:3F9E:C3F7:F64F:13E5:35A3:18B2:28A5 \
–logfile=/var/log/dnscrypt2.log

add to the and of /etc/rc

Meshed VPN

https://2kswiki.wordpress.com/2016/02/05/simple-vpn-network-mesh-with-tinc/ — centos

How to setup a site-to-site VPN using tinc in pfSense ?

https://forum.pfsense.org/index.php?topic=90536.0

https://www.tinc-vpn.org/

https://groverchou.com/blog/2017/07/23/使用-Tinc-建立-VPN-连接并配置-NAT-网关/

yum install stun

stun -v stun.sipgate.net 0

偵測後的結果,可根據 Primary log 解讀,方式如下:
“Open” = Open Internet
“Independent Mapping, Independent Filter” = Full Cone NAT
“Independedt Mapping, Address Dependendent Filter” = Restricted Core NAT
“Indepndent Mapping, Port Dependent Filter” = Port Restricted Core NAT
“Dependent Mapping” = Symmetric NAT
“Firewall” = Symmetric Firewall
“Blocked or could not reach STUN server” = UDP Blocked

http://blog.adityapatawari.com/2014/09/types-of-nat-and-how-to-determine-nat.html

Tushare

Tushare是一个免费、开源的python财经数据接口包。http://tushare.org/

#pip install pandas lxml tushare
#pip install xlrd #excel

#pip install tushare –upgrade
Beautiful Soup is a Python library for pulling data out of HTML and XML files.
pip install beautifulsoup4

import tushare
import tushare as ts
print(tushare.__version__)

即时新闻
print ts.get_latest_news();
ts.get_latest_news() #默认获取最近80条新闻数据,只提供新闻类型、链接和标题
ts.get_latest_news(top=5,show_content=True) #显示最新5条新闻,并打印出新闻内容

信息地雷
ts.get_notices()

新浪股吧
df=ts.guba_sina(show_content=True)
print df.iloc[3][‘content’]

#基本面数据

#股票列表
tushare.get_stock_basics()

#业绩报告
tushare.get_report_data(2014,3)

#盈利能力
tushare.get_profit_data(2014,3)

#营运能力
tushare.get_operation_data(2014,3)

#成长能力数据
ts.get_growth_data(2014,3)

#偿债能力数据
ts.get_debtpaying_data(2014,3)

#现金流量数据
ts.get_cashflow_data(2014,3)

交易数据

历史行情
ts.get_hist_data(‘600848’) #一次性获取全部日k线数据
ts.get_hist_data(‘600848′,start=’2017-01-05′,end=’2017-01-09’)

复权数据
df = ts.get_stock_basics()
date = df.loc[‘600848’][‘timeToMarket’] #上市日期YYYYMMDD
ts.get_h_data(‘002337’) #前复权
ts.get_h_data(‘002337′, autype=’hfq’) #后复权
ts.get_h_data(‘002337’, autype=None) #不复权
ts.get_h_data(‘002337′, start=’2015-01-01′, end=’2015-03-16’) #两个日期之间的前复权数据

ts.get_h_data(‘399106’, index=True) #深圳综合指数

实时行情
ts.get_today_all()

历史分笔
df = ts.get_tick_data(‘600848′,date=’2014-01-09’)
df.head(10)
df = ts.get_tick_data(‘600848′,date=’2018-03-12’)
df.head(10)

实时分笔
df = ts.get_realtime_quotes(‘000581’) #Single stock symbol
df[[‘code’,’name’,’price’,’bid’,’ask’,’volume’,’amount’,’time’]]

#symbols from a list
ts.get_realtime_quotes([‘600848′,’000980′,’000981’])
#from a Series
ts.get_realtime_quotes(df[‘code’].tail(10)) #一次获取10个股票的实时分笔数据

当日历史分笔
df = ts.get_today_ticks(‘601333’)
df.head(10)

大盘指数行情列表
df = ts.get_index()

大单交易数据
df = ts.get_sina_dd(‘600848′, date=’2017-12-25’) #默认400手
#df = ts.get_sina_dd(‘600848′, date=’2017-12-25’, vol=500) #指定大于等于500手的数据
票房数据

股票分类数据
行业分类
ts.get_industry_classified()
概念分类
ts.get_concept_classified()
地域分类
ts.get_area_classified()
中小板分类
ts.get_sme_classified()
创业板分类
ts.get_gem_classified()
风险警示板分类
ts.get_st_classified()
沪深300成份及权重
ts.get_hs300s()
上证50成份股
ts.get_sz50s()
中证500成份股
ts.get_zz500s()
终止上市股票列表
ts.get_terminated()
暂停上市股票列表
ts.get_suspended()

宏观经济数据
存款利率
ts.get_deposit_rate()

贷款利率
ts.get_loan_rate()
存款准备金率
ts.get_rrr()

货币供应量
ts.get_money_supply()
货币供应量(年底余额)
ts.get_money_supply_bal()
国内生产总值(年度)
ts.get_gdp_year()
国内生产总值(季度)
ts.get_gdp_quarter()
三大需求对GDP贡献
ts.get_gdp_for()
三大产业对GDP拉动
ts.get_gdp_pull()
三大产业贡献率
ts.get_gdp_contrib()
居民消费价格指数
ts.get_cpi()
工业品出厂价格指数
ts.get_ppi()

#实时票房
df = ts.realtime_boxoffice()
print(df)

#每日票房
import tushare as ts
ts.day_boxoffice() #取上一日的数据

#上一月票房
ts.month_boxoffice() #取上一月票房数据

#上一日全国影院票房排行
ts.day_cinema() #取上一日全国影院票房排行数据

Install Jupyter Notebook server and scentific packages

https://packaging.python.org/tutorials/installing-packages/#install-pip-setuptools-and-wheel

yum install python-devel

Setup Jupyter Notebook server – Centos/Rhel 7
yum -y install epel-release
yum install python-pip
python -m pip install –upgrade pip setuptools wheel
pip install ez_setup
yum groupinstall ‘Development Tools’
installed tcl/tk through:
yum install tcl
yum install tcl-devel
yum install tkinter
pip install –user ipython jupyter

#we need to configure it so we have “remote access”.
jupyter notebook –generate-config

#Writing default config to: /root/.jupyter/jupyter_notebook_config.py
#open python in the terminal with python and enter the commands below
#and remember to copy the hashed password
>>> from notebook.auth import passwd
>>> passwd()
Enter password:
Verify password:
‘sha1:d66351142f0a:9eea3d7f99e434a6837f5e73af18d03cf0353392’
>>> ctrl+z
#

vim /root/.jupyter/jupyter_notebook_config.py
#Go to linc.NotebookApp.passe #word = u”
#and remove the # and put the password in ”

# use a self-signed certificate to be able to use https://
openssl req -x509 -nodes -days 365 -newkey rsa:1024 -keyout mykey.key -out mycert.pem
vim /root/.jupyter/jupyter_notebook_config.py
c.NotebookApp.ip = ‘*’
c.NotebookApp.certfile = u’./mycert.pem’
c.NotebookApp.keyfile = u’./mykey.key’
c.NotebookApp.open_browser = False

firewall-cmd –zone=public –add-port=8888/tcp –permanent
systemctl restart firewalld

jupyter notebook

pip install –user numpy scipy matplotlib pandas sympy nose
pip install scikit-learn

yum install freetype freetype-devel
yum install gcc-gfortran
yum install blas-devel lapack-devel
yum install libpng-devel