• Home

malloc和free区别

1.malloc与free是C++/C语言的标准库函数,new/delete是C++的运算符。它们都可用于申请动态内存和释放内存。
2.对于非内部数据类型的对象而言,光用maloc/free无法满足动态对象的要求。对象在创建的同时要自动执行构造函数,对象在消亡之前要自动执行析构函数。由于malloc/free是库函数而不是运算符,不在编译器控制权限之内,不能够把执行构造函数和析构函数的任务强加于malloc/free。
3.因此C++语言需要一个能完成动态内存分配和初始化工作的运算符new,以一个能完成清理与释放内存工作的运算符delete。注意new/delete不是库函数。
4.C++程序经常要调用C函数,而C程序只能用malloc/free管理动态内存。
5.new可以认为是malloc加构造函数的执行。new出来的指针是直接带类型信息的。而malloc返回的都是void指针。

android apk破解

1 破解目的

android破解应用可以分为两类,一类纯粹的破解,获取有价值信息:如获取该资源素材、获取该应用webservice接口、代码实现、使用的开源组件等;第二类破解后修改:如本地化(汉化)、去广告、添加广告、替换资源素材等。

2 破解对象

先来看看破解对象,即后缀为apk的安装包apk,这是一个压缩包,可以直接修改后缀为zip,然后用解压工具查看。演示应用压缩包内容结构如下图。

 

apk_stru

每个应用都会包括的而且也是最重要的文件是AndroidManifest.xml 、res、assets、META-INF、classes.dex。AndroidManifest.xml是整个的配置文件,里面会包括使用到的权限、activity、service的声明等,加密;res存放定义drawable、string、layout、color的xml,通常加密;assets存放静态的资源文件,如图片、音频、视频、数据文件等,通常不加密;classes.dex是dex是Android系统中可以在Dalvik虚拟机上直接运行的文件格式,java源代码经过ADT的复杂编译后转换成Dex文件,Dalvik是Google公司自己设计用于Android平台的Java虚拟机;META-INF的文件夹,这个里边存储的是关于签名的一些信息。例如汉化通常要修改res文件夹下的字符串xml,去广告通常要修改res下布局xml,获知实现的Java代码通常通过反编译classes.dex。为了获取你想要的东西,每个可疑文件都不能放过。

 

3 如何破解

下面将从两种目的的破解介绍如何破解。

3.1查看型

查看型破解要求尽可能还原出可读信息,可读性最好的当然是源码,如Java源码,xml源码;次之为中间代码,如smali字节码;最后二进制代码,如so文件。

3.1.1 xml文件的反编译

1.使用AXMLPrinter2.jar单独反编译一个

wingyiu@mbp101:~$java -jar AXMLPrinter2.jar /User/user/V1.5.8_V4.0_demaiwebsite/AndroidManifest.xml > /User/user/demai/AndroidManifest.xml

2.使用apktool反编译全部

 wingyiu@mbp101:~/Android/apktool-install-macosx-r05-ibot$./apktool d ../V1.5.8_V4.0_demaiwebsite.apk ../demai
 I: Baksmaling...
 I: Loading resource table...
 W: Skipping "android" package group
 I: Loaded.
 I: Decoding AndroidManifest.xml with resources...
 I: Loading resource table from file: /Users/user/Library/apktool/framework/1.apk
 I: Loaded.
 I: Regular manifest package...
 I: Decoding file-resources...
 W: Cant find 9patch chunk in file: "drawable-hdpi/contact_detail_item_deep.9.png". Renaming it to *.png.
 W: Cant find 9patch chunk in file: "drawable-hdpi/message_chat_edit_normal.9.png". Renaming it to *.png.
 I: Decoding values */* XMLs...
 I: Done.
 I: Copying assets and libs...

1DFA5429-3973-484E-94A4-B2F9E67E9C37
此时res/下的xml和AndroidManifest.xml都已反编译好。smali/文件夹,里面存放着所有反编译出的smali字节码文件,按包目录结构存放。

3.1.2 classes.dex反编译

1.使用dex2jar把classes.dex转换为jar文件,可以类比为把smali转换为class

wingyiu@mbp101:~$cd Android/V1.5.8_V4.0_demaiwebsite
wingyiu@mbp101:~/Android/V1.5.8_V4.0_demaiwebsite$../dex2jar-0.0.9.15/d2j-dex2jar.sh classes.dex 
dex2jar classes.dex -> classes-dex2jar.jar

jar文件class文件的压缩包,即使直接解压无法直接阅读,此时可以使用jd-gui、jode、jad(或者他们的eclipse插件jodeclipse、jadclipse)。
2.使用jd-gui打开classes-dex2jar.jar

B5BDDAD3-72AE-4BAA-AF69-11F4833E0FCF可以看出这个应用除了第三方库做了代码混淆,其自身的代码是没有做混淆的。从报名可以大概看出该应用使用了高德地图、Google Gson等第三方库,如果不知道报名对应的库,只要把包名搜一下就知道了。虽然没混淆,但也不是所有代码都可以顺利查看的,比如下面的常量类。
32AB125A-634D-4606-8D4F-B40A3EFA0E56

 

混淆过得代码包名、类名、变量名、参数名会被无意义的a、b、aa之类代替,无法轻易理解,在一定程度上起到防反编译的效果,但效果不大。

F1865A1F-F9FC-4180-A043-2760F8E0F626

 

如果混淆过,只能通过反编译得到smali字节码文件,然后尝试从字节码文件获取信息了。

3.使用apktool反编译smali
此处不再复述,参考上面

3.1.3 so文件

未完待续

3.2 修改型

流程:通过apktool反编译整个apk,然后修改xml和smali文件或者so文件,重新打包,然后重新签名。

3.2.1 反编译,还是使用apktool

3.2.2 修改

3.2.2.1 修改静态资源

例如汉化时遇到文字是图片形式的,则可以用ps修改然后替换图片文件即可

3.2.2.2 修改xml

可以修改string、color数值,layout不可随意修改,此时可以通过修改属性值。例如把广告空间改为隐藏,或者宽高为0

3.2.2.3 修改smali

smali字节码资料参考这里。只需修改需要的地方,所以首先是定位到关键点,然后修改之。找到关键点办法:
1.资源id(通过布局xml和R类);
2.字符串(中文在smali文件里以utf8裸编码格式存储,如“\u91d1\u5e01\u4e0d\u8db3,\u65e0\u6cd5\u8d2d\u4e70”,可以通过字符转码工具来把中文转为utf8然后搜索smali文件);
3.动态调试smali(参考这里,工具如AndBug

3.2.2.4 修改so

 3.2.3 重新打包

wingyiu@mbp101:~/Android/apktool-install-macosx-r05-ibot$./apktool b ../duoxin
I: Checking whether sources has changed...
I: Smaling...
I: Checking whether resources has changed...
I: Building resources...
I: Copying libs...
I: Building apk file...

在原目录duoxin/dist就可以见到新的apk了

3.2.4 重新签名

apk还没有签名是无法安装的,开发时调试用的是debug签名。签名需要keystore文件,请参阅这里进行生成。

执行以下命令为重新编译的demai.apk签名:

$jarsigner -verbose -keystore wingyiu.keystore demai.apk Alias_name
Enter Passphrase for keystore: 
 adding: META-INF/MANIFEST.MF
 adding: META-INF/WINGYIU.SF
 adding: META-INF/WINGYIU.RSA
 signing: assets/frontia_plugin/plugin-deploy.jar
 ...
jar signed.

Warning: 
No -tsa or -tsacert is provided and this jar is not timestamped. Without a timestamp, users may not be able to validate this jar after the signer certificate's expiration date (2042-03-28) or after any future revocation date.

$zipalign -v 4 your_project_name-unaligned.apk your_project_name.apk

最后,在安装到手机前,需要把手机中的已有版本先卸载,因为如果签名不同,是不能覆盖安装的,会提示“应用程序未安装”错误。

C++11之左值、右值、左值引用、右值引用

The traditional C++ reference, now called an lvalue reference, binds an identifier to an lvalue.An lvalue is an expression, such as a variable name or a dereferenced pointer, that represents data for which the program can obtain an address. Originally, an lvalue was one that could appear on the left side of an assignment statement, but the advent of the const modifier allowed for constructs that cannot be assigned to but which are still addressable:

int n;
int * pt = new int; 
const int b = 101; // can't assign to b, but &b is valid
int & rn = n;      // n identifies datum at address &n
int & rt = *pt;    // *pt identifies datum at address pt
const int & rb = b; // b identifies const datum at address &b

C++11 adds the rvalue reference , indicated by using &&, that can bind to rvalues—that is, values that can appear on the right-hand side of an assignment expression but for which one cannot apply the address operator. Examples include literal constants (aside from C-style strings, which evaluate as addresses), expressions such as x+y, and function return values, providing the function does not return a reference:

int x = 10;
int y = 23;
int && r1 = 13;
int && r2 = x + y;
double && r3 = std::sqrt(2.0);

Note that what r2 really binds to is the value to which x + y evaluates at that time. That is, r2 binds to the value 23, and r2 is unaffected by subsequent changes to x or y.

Interestingly, binding an rvalue to an rvalue reference results in the value being stored in a location whose address can be taken.That is, although you can’t apply the & operator to 13, you can apply it to r1.This binding of the data to particular addresses is what makes it possible to access the data through the rvalue references.

One of the main reasons for introducing the rvalue reference is to implement move semantics, the next topic in this chapter.

To open “Eclipse.app”, you need a Java SE 6 runtime.Would you like to install one now

Mac更新10.10后,原来安装的java6没了,索性下了个java8,结果打开eclipse提示
To open “Eclipse.app”, you need a Java SE 6 runtime.Would you like to install one now

解决方法之一:安装apple提供的java6:
下载地址:http://support.apple.com/kb/DL1572
安装后java6和之前安装的java8可以共存

$java -version
java version "1.8.0_25"
Java(TM) SE Runtime Environment (build 1.8.0_25-b17)
Java HotSpot(TM) 64-Bit Server VM (build 25.25-b02, mixed mode)

[转]linux netstat详解

1.功能与说明

netstat 用于显示linux中各种网络相关信息。如网络链接 路由表  接口状态链接 多播成员等等。

2.参数含义介绍

-a (all)显示所有选项,默认不显示LISTEN相关
-t (tcp)仅显示tcp相关选项
-u (udp)仅显示udp相关选项
-n 拒绝显示别名,能显示数字的全部转化成数字。
-l 仅列出有在 Listen (监听) 的服務状态

-p 显示建立相关链接的程序名
-r 显示路由信息,路由表
-e 显示扩展信息,例如uid等
-s 按各个协议进行统计
-c 每隔一个固定时间,执行该netstat命令。

提示:LISTEN和LISTENING的状态只有用-a或者-l才能看到

3.常用实例

3.1  列出所有端口

 netstat -a
[root@zhz jiehun]# netstat -a|more 
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address               Foreign Address             State      
tcp        0      0 *:sunrpc                    *:*                         LISTEN      
tcp        0      0 *:webcache                  *:*                         LISTEN      
tcp        0      0 *:http                      *:*                         LISTEN      
tcp        0      0 192.168.122.1:domain        *:*                         LISTEN      
tcp        0      0 localhost.localdomain:d-s-n *:*                         LISTEN      
tcp        0      0 *:ssh                       *:*                         LISTEN      
tcp        0      0 localhost.loc:simplifymedia *:*                         LISTEN

3.2  列出所有tcp端口

[root@zhz jiehun]# netstat -at|more 
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address               Foreign Address             State      
tcp        0      0 *:sunrpc                    *:*                         LISTEN      
tcp        0      0 *:webcache                  *:*                         LISTEN      
tcp        0      0 *:http                      *:*                         LISTEN      
tcp        0      0 192.168.122.1:domain        *:*                         LISTEN      
tcp        0      0 localhost.localdomain:d-s-n *:*                         LISTEN      
tcp        0      0 *:ssh                       *:*                         LISTEN      
tcp        0      0 localhost.loc:simplifymedia *:*                         LISTEN

3.3 列出所有udp端口

 netstat -au
[root@zhz jiehun]# netstat -au|more 
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address               Foreign Address             State      
udp        0      0 *:ideafarm-panic            *:*                                     
udp        0      0 *:47005                     *:*                                     
udp        0      0 localhost.loca:memcache     *:*                                     
udp        0      0 *:55276                     *:*                                     
udp        0      0 192.168.122.1:domain        *:*                                     
udp        0      0 *:bootps                    *:*                                     
udp        0      0 *:bootpc                    *:*                                     
udp        0      0 *:sunrpc                    *:*                                     
udp        0      0 *:ipp                       *:*                                     
udp        0      0 *:44236                     *:*                                     
udp        0      0 *:722                       *:*

3.4 只显示监听端口 netstat -l

[root@zhz jiehun]# netstat -l
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address               Foreign Address             State      
tcp        0      0 *:sunrpc                    *:*                         LISTEN      
tcp        0      0 *:webcache                  *:*                         LISTEN      
tcp        0      0 *:http                      *:*                         LISTEN      
tcp        0      0 192.168.122.1:domain        *:*                         LISTEN      
tcp        0      0 localhost.localdomain:d-s-n *:*                         LISTEN      
tcp        0      0 *:ssh                       *:*                         LISTEN      
tcp        0      0 localhost.loc:simplifymedia *:*                         LISTEN      
tcp        0      0 localhost.localdomain:ipp   *:*                         LISTEN      
tcp        0      0 *:44343                     *:*                         LISTEN      
tcp        0      0 localhost.localdomain:smtp  *:*                         LISTEN

3.5 只显示监听的tcp端口 netstat -lt

[root@zhz jiehun]# netstat -lt
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address               Foreign Address             State      
tcp        0      0 *:sunrpc                    *:*                         LISTEN      
tcp        0      0 *:webcache                  *:*                         LISTEN      
tcp        0      0 *:http                      *:*                         LISTEN      
tcp        0      0 192.168.122.1:domain        *:*                         LISTEN      
tcp        0      0 localhost.localdomain:d-s-n *:*                         LISTEN      
tcp        0      0 *:ssh                       *:*                         LISTEN      
tcp        0      0 localhost.loc:simplifymedia *:*                         LISTEN      
tcp        0      0 localhost.localdomain:ipp   *:*                         LISTEN      
tcp        0      0 *:44343                     *:*                         LISTEN      
tcp        0      0 localhost.localdomain:smtp  *:*                         LISTEN

3.6 只显示所有监听udp端口 netstat -lu

[root@zhz jiehun]# netstat -lu
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address               Foreign Address             State      
udp        0      0 *:ideafarm-panic            *:*                                     
udp        0      0 *:47005                     *:*                                     
udp        0      0 *:47551                     *:*                                     
udp        0      0 localhost.loca:memcache     *:*                                     
udp        0      0 *:55276                     *:*                                     
udp        0      0 192.168.122.1:domain        *:*                                     
udp        0      0 *:bootps                    *:*                                     
udp        0      0 *:bootpc                    *:*                                     
udp        0      0 *:sunrpc                    *:*

3.7  只列出所有监听unix端口 netstat -lx

[root@zhz jiehun]# netstat -lx
Active UNIX domain sockets (only servers)
Proto RefCnt Flags       Type       State         I-Node Path
unix  2      [ ACC ]     STREAM     LISTENING     21941  /tmp/.X11-unix/X0
unix  2      [ ACC ]     STREAM     LISTENING     34096  /tmp/orbit-haozheng/linc-cd2-0-5b33fa1ecf0c9
unix  2      [ ACC ]     STREAM     LISTENING     22263  @/tmp/gdm-greeter-cBlQsyRF
unix  2      [ ACC ]     STREAM     LISTENING     32728  /tmp/.ICE-unix/3103
unix  2      [ ACC ]     STREAM     LISTENING     36866  @/tmp/dbus-AcJrBlWF
unix  2      [ ACC ]     STREAM     LISTENING     20454  /tmp/mysql.sock

3.8  显示所有端口的统计信息 netstat -s

[root@zhz jiehun]# netstat -s
Ip:
    1943780 total packets received
    2 forwarded
    0 incoming packets discarded
    1769532 incoming packets delivered
    1121573 requests sent out
    132 outgoing packets dropped
    45867 dropped because of missing route
Tcp:
    64002 active connections openings
    7632 passive connection openings
    2309 failed connection attempts
    498 connection resets received
    8 connections established
    1018564 segments received
    1022700 segments send out
    16835 segments retransmited
    2 bad segments received.
    552 resets sent
Udp:
    133420 packets received
    7845 packets to unknown port received.
    0 packet receive errors
    74841 packets sent
    0 receive buffer errors
    0 send buffer errors

3.9 显示所有tcp(netstat -st)或udp(netstat -su)的统计信息

[root@zhz jiehun]# netstat -su
IcmpMsg:
    InType0: 11
    InType3: 13506
    OutType3: 13679
    OutType8: 11
Udp:
    133462 packets received
    7869 packets to unknown port received.
    0 packet receive errors
    74888 packets sent
    0 receive buffer errors
    0 send buffer errors
UdpLite:
IpExt:
    InNoRoutes: 991
    InMcastPkts: 24308
    OutMcastPkts: 2353
    InBcastPkts: 630615
    OutBcastPkts: 1546
    InOctets: 755319900
    OutOctets: 296705252
    InMcastOctets: 2908748
    OutMcastOctets: 93173
    InBcastOctets: 99500419
    OutBcastOctets: 299980

3.10 显示pid/进程名称 netstat -p   -p可以与其他参数一起使用 比如 显示tcp的进程id信息

[root@zhz jiehun]# netstat -pt
Active Internet connections (w/o servers)
Proto Recv-Q Send-Q Local Address               Foreign Address             State       PID/Program name   
tcp        0      0 192.168.0.52:44784          123.150.49.20:http          FIN_WAIT2   4207/VirtualBox     
tcp        0      0 192.168.0.52:46715          ie-in-f125.1e100.net:https  ESTABLISHED 4207/VirtualBox     
tcp        0      0 192.168.0.52:43415          geotrust-ocsp-mtv.veri:http FIN_WAIT2   4207/VirtualBox

3.11  在 netstat 输出中不显示主机,端口和用户名 (host, port or user)当你不想让主机,端口和用户名显示,使用 netstat -n。将会使用数字代替那些名称。同样可以加速输出,因为不用进行比对查询。netstat -nltp  显示tcp的监听端口 不显示主机端口用户名 用数字代替

[root@zhz jiehun]# netstat -nltp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address               Foreign Address             State       PID/Program name   
tcp        0      0 0.0.0.0:111                 0.0.0.0:*                   LISTEN      971/rpcbind         
tcp        0      0 0.0.0.0:8080                0.0.0.0:*                   LISTEN      1526/nginx: master  
tcp        0      0 0.0.0.0:80                  0.0.0.0:*                   LISTEN      1526/nginx: master  
tcp        0      0 192.168.122.1:53            0.0.0.0:*                   LISTEN      1248/dnsmasq        
tcp        0      0 127.0.0.1:8086              0.0.0.0:*                   LISTEN      1553/python         
tcp        0      0 0.0.0.0:22                  0.0.0.0:*                   LISTEN      1163/sshd           
tcp        0      0 127.0.0.1:8087              0.0.0.0:*                   LISTEN      1553/python         
tcp        0      0 127.0.0.1:631               0.0.0.0:*                   LISTEN      1140/cupsd          
tcp        0      0 0.0.0.0:44343               0.0.0.0:*                   LISTEN      1151/rpc.statd      
tcp        0      0 127.0.0.1:25                0.0.0.0:*                   LISTEN      18573/sendmail: acc 
tcp        0      0 127.0.0.1:3002              0.0.0.0:*                   LISTEN      1004/ruby           
tcp        0      0 0.0.0.0:8000                0.0.0.0:*                   LISTEN      1526/nginx: master

个人最常用就是这个

3.12  一秒钟输出一次tcp监听端口信息 netstat -ntplc

Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address               Foreign Address             State       PID/Program name   
tcp        0      0 0.0.0.0:111                 0.0.0.0:*                   LISTEN      971/rpcbind         
tcp        0      0 0.0.0.0:8080                0.0.0.0:*                   LISTEN      1526/nginx: master  
tcp        0      0 0.0.0.0:80                  0.0.0.0:*                   LISTEN      1526/nginx: master  
tcp        0      0 192.168.122.1:53            0.0.0.0:*                   LISTEN      1248/dnsmasq        
tcp        0      0 127.0.0.1:8086              0.0.0.0:*                   LISTEN      1553/python         
tcp        0      0 0.0.0.0:22                  0.0.0.0:*                   LISTEN      1163/sshd

3.13  显示路由信息 netstat -r

[root@zhz jiehun]# netstat -r
Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
default         vrouter         0.0.0.0         UG        0 0          0 eth0
192.168.0.0     *               255.255.255.0   U         0 0          0 eth0
192.168.122.0   *               255.255.255.0   U         0 0          0 virb

3.14 显示网络接口列表 netstat -i

[root@zhz jiehun]# netstat -i
Kernel Interface table
Iface       MTU Met    RX-OK RX-ERR RX-DRP RX-OVR    TX-OK TX-ERR TX-DRP TX-OVR Flg
eth0       1500   0  4943885      0      0      0   901773      0      0      0 BMRU
lo        16436   0   236931      0      0      0   236931      0      0      0 LRU
virbr0     1500   0        0      0      0      0        0      0      0      0 BMU

 

 

Centos7 gnome3

Desktop-Install-to-Hard-Drive
CentOS 7的gnome桌面版现在使用的是Gnome 3,支持触屏。
gnome-3-Desktop
也可调成像经典Gnome 2样式。
gnome-classic
感觉比Ubuntu Unity要帅吖。

mac os x10.9.2安装pycurl

vi ~/.bash_profile
export PYCURL_CURL_CONFIG=/usr/bin/curl-config
export PYCURL_SSL_LIBRARY=openssl

$pip install pycurl

出现warning:

src/pycurl.h:152:5: warning: "libcurl was compiled with SSL support, but configure could not determine which "      "library was used; thus no SSL crypto locking callbacks will be set, which may "      "cause random crashes on SSL requests" [-W#warnings]
    #   warning \
        ^
    1 warning generated.

运行后出现

pycurl: libcurl link-time ssl backend (none/other) is different from compile-time ssl backend (openssl)

貌似和apple把curl库的openssl替换为SecureTransport有关,资料

$curl --version
$curl 7.30.0 (x86_64-apple-darwin13.0) libcurl/7.30.0 SecureTransport zlib/1.2.5
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtsp smtp smtps telnet tftp 
Features: AsynchDNS GSS-Negotiate IPv6 Largefile NTLM NTLM_WB SSL libz

还没找到解决方法啊,头疼

如果安装后出现

Fatal Python error: pycurl: libcurl link-time version is older than compile-time version

之类错误的话,应该就是你自己装了curl和mac自带的curl冲突了,导致编译和运行时加载的类库不一致,我自己安装的curl-7.33.0在/usr/local/bin下,而系统自带的7.30。0在/usr/bin

linode vps之centos 6.5配置pptp

之前参考Linode官方文档配置OpenVPN了,但是在Mac上老是连不上,决定改用PPTP试下。

PPTP依赖iptables、ppp、pptpd

1.安装iptables,如果已装跳过

yum install -y iptables

2.安装ppp

yum install -y ppp

3.安装pptpd
先安装epel源,如果已装跳过

rpm -Uvh http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm

然后

yum install -y pptpd

4.编辑/etc/pptpd.conf

#localip 192.168.0.1
#remoteip 192.168.0.234-238,192.168.0.245

修改成

localip 192.168.0.1
remoteip 192.168.0.234-238,192.168.0.245

5.编辑/etc/ppp/options.pptpd

#ms-dns 10.0.0.1
#ms-dns 10.0.0.2

改成

ms-dns 8.8.8.8
ms-dns 8.8.4.4

这里使用的是Google发布的Public DNS,您也可以修改为OpenDNS的IP,即

ms-dns 208.67.222.222
ms-dns 208.67.220.220

6.编辑/etc/ppp/chap-secrets添加pptp的用户名和密码

打开后只有两行,而且一个账号都没有

# Secrets for authentication using CHAP
# client server secret IP addresses

根据您的需要添加账号,每行一个,另一行添加
按照:“用户名 pptpd 密码 ip地址”的格式输入,每一项之间用空格分开,例如:

yongyao1 pptpd 1234 *
yongyao2 pptpd 1234 *

7.修改内核设置,使其支持转发

编辑/etc/sysctl.conf

net.ipv4.ip_forward=0

改为

net.ipv4.ip_forward=1

执行以下命令使修改后的内核生效

sysctl –p

8.添加iptables转发规则

(1)适合于OpenVZ架构的VPS,12.34.56.78为您VPS的公网IP地址

iptables -t nat -A POSTROUTING -s 192.168.0.0/24 -j SNAT –to-source 12.34.56.78

(2)适合于XEN架构的VPS

iptables -t nat -A POSTROUTING -s 192.168.0.0/24 -o eth0 -j MASQUERADE

以上两条命令分别对应OpenVZ架构和XEN架构的VPS,您的VPS是什么架构需要询问供应商。Linode采用的是XEN架构,所以输入

iptables -t nat -A POSTROUTING -s 192.168.0.0/24 -o eth0 -j MASQUERADE

保存,并重启iptables

service iptables save
service iptables restart

回报一下错

Setting chains to policy ACCEPT: security raw nat [FAILED] filter

这个出错信息可以忽略,想消除可以自行搜索解决。

9.启动pptp服务

service pptpd start

WordPress修改Google Fonts引用

装个插件Useso take over Google就好了,不用那么粗暴去改wordpress核心代码。
useso已经停止运营,这个插件也响应的更新了。
真好,墙裂推荐。

使用Devstack安装OpenStack开发环境

使用DevStack安装OpenStack纯粹是为了体验一下Openstack。如果真想研究OpenStack,建议按照官方install文档逐个安装。
 
DevStack就一个全自动shell脚本,安装过程会大量从Git仓库clone,pip和ubuntu软件源下载依赖。安装过程中问题一般都出现无法下载,所以最好还是替换一下源。

1.替换pip源,使用douban的源

新建~/.pip/pip.conf,加入

[global]
index-url = http://pypi.douban.com/simple

2.替换ubuntu源,使用163的源

  • 备份系统默认源配置文件/etc/apt/source.list
  • 将/etc/apt/source.list中的us.archive.ubuntu.com替换为mirrors.163.com
  • 将/etc/apt/source.list中的security.ubuntu.com替换为mirrors.163.com
  • sudo apt-get update

3.替换Git仓库

在clone出来的devstack文件加下新建localrc文件,加入以下

ADMIN_PASSWORD=admin
DATABASE_PASSWORD=$ADMIN_PASSWORD
RABBIT_PASSWORD=$ADMIN_PASSWORD
SERVICE_PASSWORD=$ADMIN_PASSWORD
SERVICE_TOKEN=a682f596-76f3-11e3-b3b2-e716f9080d50
GIT_BASE=http://github.com

把GIT_BASE从git.openstack.org改为github,并使用http而非https

如果还是失败,则运行unstack.sh然后重新运行stack.sh