python dir_util copy_tree errno 9

2016-10-9 python

使用python2.7.10写脚本从一个文件夹复制文件到另一个文件夹时出错

错误原因在读取源文件时找不到文件描述

errno 9

但是通过python idle执行可以,后来把python更新到2.7.12版本就可以了

可能是2.7.10 bug吧

运行环境 windows 2008 64位 英文版

标签: python

评论(0) 浏览(442)

vps ubuntu 搭建 ipsec l2tp vpn服务器

2016-9-19 vpn

由于升级了ios10,ios10不支持pptp vpn服务器连接,因此重新安装了下vpn服务器采用ipsec + xl2tpd

参考:https://raymii.org/s/tutorials/IPSEC_L2TP_vpn_with_Ubuntu_14.04.html


1.安装ppp openswan xl2tpd

sudo apt-get install openswan xl2tpd ppp lsof

2.设置防火墙,如果没设置的话连接成功后没办法接上外网

iptables -t nat -A POSTROUTING -j SNAT --to-source vps主机ip -o eth0(主机ip网卡)

修改/etc/sysctl.conf设置以下几个选项:

net.ipv4.ip_forward = 1

net.ipv4.conf.all.accept_redirects = 0

net.ipv4.conf.all.send_redirects = 0

net.ipv4.conf.default.rp_filter = 0

net.ipv4.conf.default.accept_source_route = 0

net.ipv4.conf.default.send_redirects = 0

net.ipv4.icmp_ignore_bogus_error_responses = 1

然后sudo sysctl -p应用他们

可以通过修改/etc/rc.local实现开机设置:把如下一条命令放在exit 0之前

iptables -t nat -A POSTROUTING -j SNAT --to-source vps主机ip -o eth0(主机ip网卡)

3.配置ipsec /etc/ipsec.conf

version 2 # conforms to second version of ipsec.conf specification

config setup
    dumpdir=/var/run/pluto/
    #in what directory should things started by setup (notably the Pluto daemon) be allowed to dump core?

    nat_traversal=yes
    #whether to accept/offer to support NAT (NAPT, also known as "IP Masqurade") workaround for IPsec

    virtual_private=%v4:10.0.0.0/8,%v4:192.168.0.0/16,%v4:172.16.0.0/12,%v6:fd00::/8,%v6:fe80::/10
    #contains the networks that are allowed as subnet= for the remote client. In other words, the address ranges that may live behind a NAT router through which a client connects.

    protostack=netkey
    #decide which protocol stack is going to be used.

    force_keepalive=yes
    keep_alive=60
    # Send a keep-alive packet every 60 seconds.

conn L2TP-PSK-noNAT
    authby=secret
    #shared secret. Use rsasig for certificates.

    pfs=no
    #Disable pfs

    auto=add
    #the ipsec tunnel should be started and routes created when the ipsec daemon itself starts.

    keyingtries=3
    #Only negotiate a conn. 3 times.

    ikelifetime=8h
    keylife=1h

    ike=aes256-sha1,aes128-sha1,3des-sha1
    phase2alg=aes256-sha1,aes128-sha1,3des-sha1
    # https://lists.openswan.org/pipermail/users/2014-April/022947.html
    # specifies the phase 1 encryption scheme, the hashing algorithm, and the diffie-hellman group. The modp1024 is for Diffie-Hellman 2. Why 'modp' instead of dh? DH2 is a 1028 bit encryption algorithm that modulo's a prime number, e.g. modp1028. See RFC 5114 for details or the wiki page on diffie hellmann, if interested.

    type=transport
    #because we use l2tp as tunnel protocol 
		

left=vps主机ip

#fill in server IP above leftprotoport=17/1701 right=%any rightprotoport=17/%any dpddelay=10 # Dead Peer Dectection (RFC 3706) keepalives delay dpdtimeout=20 # length of time (in seconds) we will idle without hearing either an R_U_THERE poll from our peer, or an R_U_THERE_ACK reply. dpdaction=clear # When a DPD enabled peer is declared dead, what action should be taken. clear means the eroute and SA with both be cleared.
4.设置共享密匙 /etc/ipsec.secrets

vps主机ip %any: PSK "随便字符串"

5.验证ipsec设置

ipsec verify

Checking your system to see if IPsec got installed and started correctly:
Version check and ipsec on-path                                 [OK]
Linux Openswan U2.6.38/K3.13.0-24-generic (netkey)
Checking for IPsec support in kernel                            [OK]
 SAref kernel support                                           [N/A]
 NETKEY:  Testing XFRM related proc values                      [OK]
    [OK]
    [OK]
Checking that pluto is running                                  [OK]
 Pluto listening for IKE on udp 500                             [OK]
 Pluto listening for NAT-T on udp 4500                          [OK]
Checking for 'ip' command                                       [OK]
Checking /bin/sh is not /bin/dash                               [WARNING]
Checking for 'iptables' command                                 [OK]
Opportunistic Encryption Support                                [DISABLED]
6.配置xl2tpd.conf

[global]
ipsec saref = yes
saref refinfo = 30

;debug avp = yes
;debug network = yes
;debug state = yes
;debug tunnel = yes

[lns default]
ip range = 192.168.1.20-192.168.1.100
local ip = 192.168.1.1
refuse pap = yes
require authentication = yes
;ppp debug = yes
pppoptfile = /etc/ppp/options.xl2tpd
length bit = yes
7.配置ppp /etc/ppp/options.xl2tpd 

require-mschap-v2
ms-dns 8.8.8.8
ms-dns 8.8.4.4
auth
mtu 1200
mru 1000
crtscts
hide-password
modem
name l2tpd
proxyarp
lcp-echo-interval 30
lcp-echo-failure 4

8.添加用户 /etc/ppp/chap-secrets

bob            l2tpd   DF98F09F74C06A2F             *

10.重启服务

/etc/init.d/ipsec restart 
/etc/init.d/xl2tpd restart
问题1:

Two or more interfaces found, checking IP forwarding        [FAILED]

这个可以不用管,通过echo 0 > /proc/sys/net/ipv4/ip_forward 可以解决,但是这样就没办法上外网了


问题2:

"L2TP-PSK-noNAT"[33]  #33: STATE_QUICK_R2: IPsec SA established transport mode {DPD=enabl}

拨号上去到出现上面语句后后就没相应了,原因是配置文件漏了,重新检查下配置文件就可以了

		


标签: vpn ipsec l2tp

评论(0) 浏览(845)

健身日志

2016-9-10 健身

8.26-9.9腹肌变化,加油。。。。

IMG_5354.jpg

IMG_5370.jpg

IMG_5401.jpg

IMG_5427.jpg

IMG_5497.jpg

评论(0) 浏览(477)

解决“应用程序无法启动,应用程序的并行配置不正确”

2016-9-10 C++

应用程序事件日志中:

“xxx.exe”的激活上下文生成失败。 找不到从属程序集 Microsoft.VC80.MFC,processorArchitecture="amd64",publicKeyToken="1fc8b3b9a1e18e3b",type="win32",version="8.0.50727.762"。 请使用 sxstrace.exe 进行详细诊断。

出现这类问题,是由于VS2008编译出来的程序文件,采用了manifest方式来指定dll文件。解决办法把相应的dll及mainifest放到程序目录底下


解决办法
在类似C:/Program Files/Microsoft Visual Studio 9/VC/redi
st/Debug_NonRedist/amd64Microsoft.VC80.DebugCRT 下找到了下列文件:

msvcm80d.dll
msvcp80d.dll
msvcr80d.dll
Microsoft.VC80.DebugCRT.manifest

把这几个文件拷贝到目标机器上,与运行程序同一文件夹


标签: MFC

评论(0) 浏览(535)

2016-9-6

迷茫。。。。。。。。。。。。。。。。。。。。

评论(0) 浏览(287)

vps ubuntu 通过pptpd freeradius radiusclient搭建vpn服务器

2016-8-15 vpn

vps服务器使用的是digitalocean服务器。地址为https://www.digitalocean.com/

pptpd跟freeradius radiusclient配合网上教程很多,大部分教程都是大同小异,前面参考了好多配置都是死活不成功!

今天重新下载配置了下,奇迹般的可以了!后面总结出来应该是设置账号的时候设置为之错了!

新增帐号应该放在/etc/freeradius/users 里面原先的测试帐号steve的位置下面,不应该放在文件末尾

最后参考的pptpd等配置网址为:

http://www.cnblogs.com/klobohyz/archive/2012/02/04/2338675.html

http://www.cnblogs.com/klobohyz/archive/2012/02/01/2334811.html

另radius读取/usr/local/etc/radiusclient/dictionary 配置出现了不识别的类型,把如下的注释掉就可以

#

#       RFC3162 IPv6 attributes

#

#ATTRIBUTE      NAS-IPv6-Address        95      string

#ATTRIBUTE      Framed-Interface-Id     96      string

#ATTRIBUTE      Framed-IPv6-Prefix      97      ipv6prefix

#ATTRIBUTE      Login-IPv6-Host         98      string

#ATTRIBUTE      Framed-IPv6-Route       99      string

#ATTRIBUTE      Framed-IPv6-Pool        100     string

#

#       RFC6911 IPv6 attributes

#

#ATTRIBUTE      Framed-IPv6-Address     168     ipv6addr

#ATTRIBUTE      DNS-Server-IPv6-Address 169     ipv6addr

#ATTRIBUTE      Route-IPv6-Information  170     ipv6prefix



标签: vpn pptpd freeradius radiusclient

评论(0) 浏览(425)

6.4-6.11台湾行

2016-6-16 摄影

6.4深圳-桃园机场-高雄-垦丁

6.5垦丁

6.6垦丁-高雄-台中-蓬甲夜市

6.7台中-日月潭-台中-台北

6.8故宫博物馆-淡水中学-淡水老街-士林夜市

6.9mr.j餐厅-诚品书店-微风广场-电影-101-鼎泰丰-base10夜店

6.10台北-瑞芳-十分-猫园-九份-宁夏夜市

6.11 台北-王品-桃园机场-深圳

标签: 台湾 旅游

评论(0) 浏览(477)

通过HWND获取WebBrowser内容

2016-4-20 C++

参考资料:https://support.microsoft.com/en-us/kb/249232

已知一个窗口的HWND及窗口类为“Internet Explorer_Server",获取显示的内容!

#include <mshtml.h>

#include <atlbase.h>

#include <oleacc.h>


BOOL CALLBACK EnumChildProc(HWND hwnd, LPARAM lParam)

{

    TCHAR buf[256] = { 0 };

    ::GetClassName(hwnd, buf, 256);

    if (_tcscmp(buf, _T("Internet Explorer_Server")) == 0)

    {

        *(HWND*)lParam = hwnd;

        return FALSE; //退出循环

    }

    return TRUE;

}


void GetDocInterface(HWND hWnd)

{

    CoInitialize(NULL);

    HINSTANCE hInst = ::LoadLibrary(_T("OLEACC.DLL");

    if (hInst != NULL && hWnd != NULL)

    {

        HWND hWndChild = NULL;

        ::EnumChildWindows(hWnd, EnumChildProc, (LPARAM)&hWndChild);

        if (hWndChild)

        {

            CComPtr<IHTMLDocument2> spDoc;

            LRESULT lRes;

            

            UINT nMsg = ::RegisterWindowMessage(_T("WM_HTML_GETOBJECT"));

            ::SendMessageTimeout(hWndChild, nMsg, 0L, 0L, SMTO_ABORTIFHUNG, 1000, (DWORD*)&lRes);

            LPFNOBJECTFROMLRESULT pfObjectFromLresult = (LPFNOBJECTFROMLRESULT)::GetProcAddress(hInst, _T("ObjectFromLresult"));

            if (pfObjectFromLresult != NULL)

            {

                HRESULT hr = (*pfObjectFromLresult )(lRes, IID_IHTMLDocument2, 0, (void**)&spDoc);

                if (SUCCEEDED(hr))

                {

                    IHTMLElement *p = NULL;

                    spDoc->get_body(&p); //接下去就跟操作IE一样

                }

            }

        }

        ::FreeLibrary(hInst);

    }

    ::CoUninitialize();

}

标签: HWND Internet Explorer_Server

评论(0) 浏览(574)

android 开启wifi热点api

2016-3-13 android

android默认开启wifi热点方式只能通过设置-移动网络共享-便携式wlan热点,为了开启一个热点要进行3部操作,实属麻烦!

因此通过网上查资料,实现wifi热点的一键启动!

通过google获知,android把wifi相关的api给隐藏了,因此只能通过反射机制进行调用!

  /**

    * Start AccessPoint mode with the specified

    * configuration. If the radio is already running in

    * AP mode, update the new configuration

    * Note that starting in access point mode disables station

    * mode operation

    * @param wifiConfig SSID, security and channel details as

    *        part of WifiConfiguration

    * @return {@code true} if the operation succeeds, {@code false} otherwise

    *

    * @hide Dont open up yet

    */

   public boolean setWifiApEnabled(WifiConfiguration wifiConfig, boolean enabled) {

       try {

           mService.setWifiApEnabled(wifiConfig, enabled);

           return true;

       } catch (RemoteException e) {

           return false;

       }

   }

配置AP的选项是属于wifi管理的一部分!获取当前系统wifi实例的方式如下:

WifiManger manager = (WifiManager) getSystemService(Context.WIFI_SERVICE);

获取当前ap状态的方式如下:

public Boolean getApState() {

    Boolean bApState = FALSE;

    try {

             Method method = manager.getClass().getMethod("isWifiApEnabled");

             bApState = (Boolean)method.invoke(manager);

     } catch (Exception e) {

        e.printStackTrace();

         bApState = FALSE;

    }

    return bApState;

}

配置ap使用的类为:WifiConfiguration //本例直接采用默认配置好的

public WifiConfiguration getApConfiguration() {

    WifiConfiguration apConfigure = new WifiConfiguretion();

    return apConfigure;

}

      使能ap方式如下:

public void setWifiAp(Boolean bOpen) {

    if (bOpen) {

        if (getApState()) {

            return;

        }

        manager.setWifiEnabled(false);

    }

    try {

       Method method = manager.getClass().getMethod("setWifiApEnabled", WifiConfiguration.class, Boolean.TYPE);

       method.invoke(manager, getApConfiguration()/*采用默认的配置,则置为null*/, bOpen);

    } catch (Exception e) {

        e.printStackTrance();

    }

}

源码已上传到github:https://github.com/aqi/WifiAssistant

标签: android wifiAp

评论(0) 浏览(1132)

Powered by EMLOG Copyright @ 狼酒 版权所有. 闽ICP备14012694号-2