未分类 - XiZi's Blog
修改linux的时间显示格式
1、 设置时间样式
export TIME_STYLE=long-iso
Beatiful. Worked lika charm. Just wish I’ve looked into this earlier. Like a few years ago… Oh, well.
2、其他方式可以参考如下网页
Git for windows 用户名 变为 【计算机名+用户名】 的形式
如果git for windows 的使用者发先自己的用户名前面多了计算机名,即 `计算机名+用户名` 的形式, 这是由于你的计算机加入了域引起的。具体参照官方的文档:https://cygwin.com/cygwin-ug-net/ntsec.html#ntsec-mapping-how
解决方法是创建/etc/passwd 文件, 手动修改用户名。
创建/etc/passwd
mkpasswd > /etc/passwd
修改/etc/passwd 文件
去掉相应的域名或计算机名即可
这里记录一个用CreatePipe的坑
1. 问题来源:在Windows上编译了一个cgit, 加了source-filter,代码高亮(使用highlight处理)之后,死活不显示代码。发现是execvp的问题,开始想好好弄,后来放弃了,反正只加个代码高亮,直接dirtry的解决方案算了。所以就参照微软的官方<Creating a Child Process with Redirected Input and Output>, 进行highlight进程的创建。测试小文件可以正常高亮,大文件就会卡住。
2.问题所在和解决方案:经过各种查找,定位到了WriteFile给子线程的Stdin pipe时发生了阻塞。查了查,发现CreatePipes时,有buffersize的设置,增大buffersize, 问题得到了解决。
贴出Dirty的核心代码吧:
-
#define _WIN32_WINNT 0x0600 #define WIN32_LEAN_AND_MEAN #include <windows.h> #include <winnt.h> #include <winternl.h> #include <stdio.h> #include <errno.h> #include <assert.h> #include <process.h> typedef struct ProcessPrepare_Info { PROCESS_INFORMATION child_pi; HANDLE IN_Rd; HANDLE IN_Wr; HANDLE OUT_Rd; HANDLE OUT_Wr; } PPInfo; #define BUFSIZE 4096 #define PIPE_BUFSIZE 1024*1024*1024
-
PPInfo prepare_highlight(const char* filename) { SECURITY_ATTRIBUTES saAttr; char file_ext[1024]; char *fext; PPInfo ppinfo; PROCESS_INFORMATION child_pi; HANDLE g_hChildStd_IN_Rd = NULL; HANDLE g_hChildStd_IN_Wr = NULL; HANDLE g_hChildStd_OUT_Rd = NULL; HANDLE g_hChildStd_OUT_Wr = NULL; fext = get_filename_ext(filename); if (!fext) strcpy(file_ext,"txt"); else strcpy(file_ext,fext); if (strstr(filename,"Makefile") == filename) strcpy(file_ext,"mk"); // printf("\n->Start of parent execution.\n"); // Set the bInheritHandle flag so pipe handles are inherited. saAttr.nLength = sizeof(SECURITY_ATTRIBUTES); saAttr.bInheritHandle = TRUE; saAttr.lpSecurityDescriptor = NULL; // Create a pipe for the child process's STDOUT. if (!CreatePipe(&g_hChildStd_OUT_Rd, &g_hChildStd_OUT_Wr, &saAttr, PIPE_BUFSIZE)) debug_log(TEXT("StdoutRd CreatePipe")); // Ensure the read handle to the pipe for STDOUT is not inherited. if (!SetHandleInformation(g_hChildStd_OUT_Rd, HANDLE_FLAG_INHERIT, 0)) debug_log(TEXT("Stdout SetHandleInformation")); // Create a pipe for the child process's STDIN. if (!CreatePipe(&g_hChildStd_IN_Rd, &g_hChildStd_IN_Wr, &saAttr, PIPE_BUFSIZE)) debug_log(TEXT("Stdin CreatePipe")); // Ensure the write handle to the pipe for STDIN is not inherited. if (!SetHandleInformation(g_hChildStd_IN_Wr, HANDLE_FLAG_INHERIT, 0)) debug_log(TEXT("Stdin SetHandleInformation")); // Create the child process. child_pi = CreateChildProcess(file_ext,g_hChildStd_OUT_Wr,g_hChildStd_IN_Rd); debug_log("Create highlight process finished.\n"); ppinfo.child_pi = child_pi; ppinfo.IN_Rd = g_hChildStd_IN_Rd; ppinfo.IN_Wr = g_hChildStd_IN_Wr; ppinfo.OUT_Rd = g_hChildStd_OUT_Rd; ppinfo.OUT_Wr = g_hChildStd_OUT_Wr; return ppinfo; }
-
void wait_highlight(PPInfo ppinfo) { //WaitForSingleObject(ppinfo.child_pi.hProcess, INFINITE); WaitForSingleObject(ppinfo.child_pi.hProcess, 10000); if (!CloseHandle(ppinfo.OUT_Wr)) debug_log(TEXT("Child StdOutWr CloseHandle")); // Read from pipe that is the standard output for child process. //printf("\n->Contents of child process STDOUT:\n\n", argv[1]); ReadFromPipe(ppinfo.OUT_Rd); //printf("\n->End of parent execution.\n"); // The remaining open handles are cleaned up when this process terminates. // To avoid resource leaks in a larger application, close handles explicitly. }
-
DWORD WriteBufToPipe(HANDLE wHandle,const char* buf, DWORD bufsize) // Read from a file and write its contents to the pipe for the child's STDIN. // Stop when there is no more data. { int i, dwRead; DWORD dwWritten; CHAR chBuf[BUFSIZE+1]; BOOL bSuccess = FALSE; chBuf[BUFSIZE] = 0; #if false bSuccess = WriteFile(wHandle, buf, bufsize, &dwWritten, NULL); #else i=0; for (;;) { //bSuccess = ReadFile(g_hInputFile, chBuf, BUFSIZE, &dwRead, NULL); //if (!bSuccess || dwRead == 0) break; dwRead = (bufsize - BUFSIZE*i); if ( dwRead <= 0) break; dwRead = min(dwRead+1,BUFSIZE); memcpy(chBuf,&(buf[BUFSIZE*i]),dwRead); debug_log("Write %d bytes of chbuf %s to handle\n",dwRead,chBuf); bSuccess = WriteFile(wHandle, chBuf, dwRead, &dwWritten, NULL); debug_log("Write buf %d time,bSuccess=%d\n",i,bSuccess); if (!bSuccess) break; FlushFileBuffers(wHandle); debug_log("Flush write handle.\n"); i=i+1; } #endif debug_log("Write buf finished\n"); // Close the pipe handle so the child process stops reading. if (!CloseHandle(wHandle)) debug_log(TEXT("StdInWr CloseHandle")); return dwWritten; }
-
PROCESS_INFORMATION CreateChildProcess(const char* file_ext,HANDLE hOutput, HANDLE hInput) // Create a child process that uses the previously created pipes for STDIN and STDOUT. { TCHAR szCmdline[1024] = TEXT("D:\\Data\\WebRoot\\cgit\\highlight-3.39-x64\\highlight.exe --force --inline-css -f -I -O xhtml -S "); PROCESS_INFORMATION piProcInfo; STARTUPINFO siStartInfo; BOOL bSuccess = FALSE; //Append file extension strcat(szCmdline,file_ext); debug_log("%s\n",szCmdline); // Set up members of the PROCESS_INFORMATION structure. ZeroMemory(&piProcInfo, sizeof(PROCESS_INFORMATION)); // Set up members of the STARTUPINFO structure. // This structure specifies the STDIN and STDOUT handles for redirection. ZeroMemory(&siStartInfo, sizeof(STARTUPINFO)); siStartInfo.cb = sizeof(STARTUPINFO); siStartInfo.hStdError = hOutput;//g_hChildStd_OUT_Wr; siStartInfo.hStdOutput = hOutput;//g_hChildStd_OUT_Wr; siStartInfo.hStdInput = hInput;//g_hChildStd_IN_Rd; siStartInfo.dwFlags |= STARTF_USESTDHANDLES; // Create the child process. bSuccess = CreateProcess(TEXT("D:\\Data\\WebRoot\\cgit\\highlight-3.39-x64\\highlight.exe"), szCmdline, // command line NULL, // process security attributes NULL, // primary thread security attributes TRUE, // handles are inherited 0, // creation flags NULL, // use parent's environment NULL, // use parent's current directory &siStartInfo, // STARTUPINFO pointer &piProcInfo); // receives PROCESS_INFORMATION // If an error occurs, exit the application. if (!bSuccess) debug_log(TEXT("CreateProcess Failed.")); else { // Close handles to the child process and its primary thread. // Some applications might keep these handles to monitor the status // of the child process, for example. CloseHandle(piProcInfo.hProcess); CloseHandle(piProcInfo.hThread); } return piProcInfo; }
-
const char *get_filename_ext(const char *filename) { const char *dot = strrchr(filename, '.'); if(!dot || dot == filename) return NULL; return dot + 1; }
-
Test Main Code
int test_process2(const char* filename,const char* buf, DWORD bufsize) { PPInfo cIn; int i, dwRead; DWORD dwWritten; CHAR chBuf[BUFSIZE+1]; BOOL bSuccess = FALSE; chBuf[BUFSIZE] = 0; debug_log("test_process2 start.\n"); cIn=prepare_highlight(filename); //WriteToPipe(cIn.IN_Wr,g_hInputFile); i=0; for (;;) { //bSuccess = ReadFile(g_hInputFile, chBuf, BUFSIZE, &dwRead, NULL); //if (!bSuccess || dwRead == 0) break; dwRead = (bufsize - BUFSIZE*i); if ( dwRead <= 0) break; dwRead = min(dwRead+1,BUFSIZE); memcpy(chBuf,&(buf[BUFSIZE*i]),dwRead); debug_log("Write %d bytes of chbuf %s to handle\n",dwRead,chBuf); bSuccess = WriteFile(cIn.IN_Wr, chBuf, dwRead, &dwWritten, NULL); debug_log("Write buf %d time\n",i); if (!bSuccess) break; i=i+1; } debug_log("Write buf finished\n"); // Close the pipe handle so the child process stops reading. if (!CloseHandle(cIn.IN_Wr)) debug_log(TEXT("StdInWr CloseHandle")); wait_highlight(cIn); debug_log("test_process2 finished.\n"); return 0; }
PS:
这里在顺便提一下,如何在Windows下编译cgit, 下载并安装git-sdk,然后在打开的shell里面make即可。之后拷贝到Apache相关目录并设置即可。
apache + gerrit + gitweb on windows 的配置
折腾了几天终于比较完整的搞定了。
电脑运行Windows Server 2008R2 with SP1,Java 1.6.0_45 x86版。
1、需要的软件
msysgit(1.8.3),gerrit(2.8.4),apache(2.4.9),gerrit_service(git commit 29aa688d2312feeca1130ac96eed9a3810088e03)
括号内为当前使用的版本。
2、安装msysgit,apache,获取gerrit,及gerrit_service的源代码。
这里仅给出gerrit_service的git repo:https://github.com/asankah/gerrit_service.git
3、Apache 配置
这里我们使用VirtualHost并开启SSL加密,配置二级域名gerrit.fengtech.com提供review服务。配置本地客户端使用用户名密码/证书进行认证,internet客户端必须使用客户端证书进行认证。
#重定向普通端口的访问到SSl端口 <VirtualHost *:80> ServerName gerrit.fengtech.com Redirect / https://gerrit.fengtech.com/ </VirtualHost>
#在开启了SSL的443端口配置虚拟主机 <VirtualHost *:443> ServerAdmin xifeng.ren@gmail.com ServerName gerrit.fengtech.com ErrorLog "logs/error_log_ssl" TransferLog "logs/access_log_ssl" SSLEngine on SSLProtocol all -SSLv2 SSLCipherSuite HIGH:MEDIUM:!aNULL:!MD5 SSLCertificateFile "D:/path/to/conf/ssl/keys/.fengtech.com.crt" SSLCertificateKeyFile "D:/path/to/conf/ssl/keys/.fengtech.com.key" SSLVerifyClient none #配置客户端验证ca SSLCACertificateFile "D:/path/to/conf/ssl/keys/ca.crt" #配置客户端验证ca的吊销列表 SSLCARevocationFile "D:/path/to/conf/ssl/keys/ca.crl" SSLCARevocationCheck chain #配置代理把连接转向gerrit服务器 ProxyRequests Off ProxyVia Off ProxyPreserveHost On <Proxy *> Order deny,allow Allow from all </Proxy> #这里我们配置/login/需要认证,我们也可以设置所有的连接都需要真正,把"/login/"换成"/"即可,不包含引号. <Location /login/> SSLVerifyClient optional SSLOptions +FakeBasicAuth SSLOptions +StrictRequire # Force clients from the Internet to use HTTPS #RewriteEngine on #RewriteCond %{REMOTE_ADDR} !^192\.168\.1\.[0-9]+$ #RewriteCond %{HTTPS} !=on #RewriteRule . - [F] # Allow Network Access and/or Basic Auth <requireall> # Network Access Control Require ip ::1 127 10 219.217.159.76 # HTTP Basic Authentication AuthType basic AuthName "Gerrit Code Review" AuthBasicProvider file AuthUserFile D:/path/to/htpasswd Require valid-user </requireall> <requireall> SSLVerifyDepth 5 SSLRequire %{SSL_CIPHER_USEKEYSIZE} >= 128 AuthBasicFake %{SSL_CLIENT_S_DN_CN} %{sha1:passphrase-%{SSL_CLIENT_S_DN_CN}} Require ssl-verify-client </requireall> </Location> AllowEncodedSlashes On #这里我们使用127.0.0.1:8081是我们后面要配置的gerrit服务监听的地址和端口。 ProxyPass / http://127.0.0.1:8081/ nocanon ProxyPassReverse / http://127.0.0.1:8081/ <FilesMatch "\.(cgi|shtml|phtml|php)$"> SSLOptions +StdEnvVars </FilesMatch> <Directory "D:/path/to/WebRoot/cgi-bin"> SSLOptions +StdEnvVars </Directory> BrowserMatch "MSIE [2-5]" \ nokeepalive ssl-unclean-shutdown \ downgrade-1.0 force-response-1.0 CustomLog "logs/ssl_request_log_gerrit" \ "%t %h %u %{SSL_CLIENT_S_DN_CN}x %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b" </VirtualHost>
好了接下来配置gerrit。
4、gerrit的配置与安装。
gerrit需要java环境,x86或者x86_64均可,要求1.6以上版本。这里使用的是sun java1.6.0_45 x64的版本。
所有gerrit,去google下载war包,我下载的是gerrit-2.8.4.war。
配置gerrit目录
D:\Developer\WebRoot>java -jar gerrit-2.8.4.war init -d gerrit_git *** Gerrit Code Review 2.8.4 *** Create 'D:\Developer\WebRoot\gerrit_git' [Y/n]?y *** Git Repositories *** Location of Git repositories [git]:git *** SQL Database *** Database server type [h2]:h2 *** User Authentication *** 这里改为http的认证方式,使用我们刚才配置的apache认证。 Authentication method [OPENID/?]: http Get username from custom HTTP header [y/N]? SSO logout URL : *** Email Delivery 这里我们先采用默认设置稍后再更改邮件发送服务器设置。 *** SMTP server hostname [localhost]: SMTP server port [(default)]: SMTP encryption [NONE/?]: SMTP username [Administrator]: Administrator's password : confirm password : *** Container Process *** Run as [Administrator]: Java runtime [D:\Program Files\Java\jdk1.6.0_45\jre]: Copy gerrit-2.8.4.war to D:\Developer\WebRoot\gerrit_git\bin\gerrit.war [Y/n]? *** SSH Daemon *** 监听地址*,方便可以远程使用ssh协议clone和push代码,否则可以改为127.0.0.1,近监听本地端口。 Listen on address [*]: Listen on port [29418]: Gerrit Code Review is not shipped with Bouncy Castle Crypto v144 If available, Gerrit can take advantage of features in the library, but will also function without it. Download and install it now [Y/n]? y Generating SSH host key ... rsa(simple)... done *** HTTP Daemon *** 这里我们仅监听127.0.0.1这个地址即可,供给本机apache使用,当然如果使用不同的服务器,需要配置合适的监听地址。端口采用8081与apache里面的配置相对应。canonical url 使用我们的二级域名gerrit.fengtech.com Behind reverse proxy [y/N]? y Proxy uses SSL (https://) [y/N]? y Subdirectory on proxy server [/]: Listen on address [*]: 127.0.0.1 Listen on port [8081]: 8081 Canonical URL [https://127.0.0.1/]: https://gerrit.fengtech.com / *** Plugins *** 以下的plugin可以选择N,即默认。 Install plugin download-commands version v2.8.4 [y/N]? y Install plugin reviewnotes version v2.8.4 [y/N]? y Install plugin replication version v2.8.4 [y/N]? y Install plugin commit-message-length-validator version v2.8.4 [y/N]? y *** 提示配置完成,但没有自动启动,我们需要用gerrit_service配置启动gerrit Server。 Initialized D:\Developer\WebRoot\gerrit_git Automatic startup not supported on Win32.
接下来贴一下配置的结果,配置文件再gerrit目录的etc文件夹里面
[gerrit] basePath = git canonicalWebUrl = https://gerrit.fengtech.com/ [database] type = h2 database = db/ReviewDB [auth] type = HTTP [sendemail] smtpServer = smtp.gmail.com smtpServerPort = 465 smtpEncryption = ssl smtpUser = username@gmail.com smtpPass = password sslVerify = false from = Code Review <username@gmail.com> [container] user = Administrator javaHome = D:\\Program Files\\Java\\jdk1.6.0_45\\jre [sshd] listenAddress = *:29418 [httpd] listenUrl = proxy-https://127.0.0.1:8081/ [cache] directory = cache [gitweb] ;这个文件是我们一会儿要创建的对perlcgi的一个wrap,要么在windows下运行不了gitweb. cgi = /D:/path/to/Git/share/gitweb/gitweb.bat
gitweb.bat
@echo off rem 这里一定要使用git提供的perl. @"D:\Developer\Git\bin\perl.exe" "D:\Developer\Git\share\gitweb\gitweb.cgi" %*
gitweb.cgi
修改gitweb.cgi的变量
our $GIT = "D:/Developer/Git/bin/git"; 指定git
our $projectroot = "/path/to/GitRepos"; git respons 的目录
5、安装和配置gerrit_service服务。
获取源代码:git clone https://github.com/asankah/gerrit_service.git
具体是的使用参见clone得到的文档,这里仅给出用到的命令。
编译 cl /EHsc gerrit_service.cpp
安装 拷贝gerrit_service.exe 到 gerrit\bin目录
添加服务 gerrit_service.exe -j "d:\path\to\javahome" -d "d:\path\to\gerrit" -i -a apacheuser -p apachepassword
PS:注意这里一定到使用一个账户,不能用"本地系统账户",否者在配置使用cgi即gitweb的时候,打开gitweb页面非常慢,甚至停止反应。推荐新建apacheuser账户,把apache Server和 gerrit_service 都使用这个账户。
Build Apache On Windows
0、为目标平台准备 perl,zlib,pcre,openssl。
perl需要安装并加入到PATH环境变量里。pcre和httpd的编译都要用到。
zlib和pcre均使用cmake编译,这里就不说了。
openssl 的编译,按照源文件下的INSTALL进行编译,注意有win32,win64a,win64i之分。并enable-zlib。
1、使用window版本的源代码:
apr-1.5.0-win32-src.zip,apr-iconv-1.2.1-win32-src-r2.zip,apr-util-1.5.3-win32-src.zip
2、全部解压到当前目录
创建并重命名或者创建符号链接,去掉版本号即目录下:apr,apr-iconv,apr-util.
3、这里我们使用visual studio 编译:
1)IED编译。打开apr-util下的aprutil.dsw,会提示转换。选择是进行转换。然后尝试编译。
2)命令行编译。打开vs command promote 命令行,进入apr-util目录
NMAKE /f "libaprutil.mak" CFG="libaprutil - Win32 Release" REM "libaprutil - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") REM "libaprutil - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") REM "libaprutil - x64 Release" (based on "Win32 (x86) Dynamic-Link Library") REM "libaprutil - x64 Debug" (based on "Win32 (x86) Dynamic-Link Library")
这里要修改原来的文件的一处错误:
--- apr-iconv-1.2.1.orig\build\modules.mk.win Fri Oct 19 04:49:36 2007 +++ apr-iconv-1.2.1\build\modules.mk.win Mon Apr 21 14:56:22 2014 @@ -218,7 +218,7 @@ .c{$(OUTPUT_DIR)}.so: $(SILENT)cl $(ALL_CFLAGS) /Fo$*.obj /Yuiconv.h /c $< - $(SILENT)link $(ALL_LDFLAGS) $*.obj $(API_LIBS) /out:$@ \ + $(SILENT)link $(ALL_LDFLAGS) $*.obj $(MODRES).obj $(API_LIBS) /out:$@ \ /base:@"..\build\BaseAddr.ref",$(@F) $(SILENT)if exist $@.manifest \ $(SILENT)mt -nologo -manifest $@.manifest -outputresource:$@;2 \
4、编译httpd之前的准备
1)这里我们要把所有的include文件合并到一起,要门cmake进行configure的时候会出错。 拷贝apr,apr-iconv和apr-util下的include文件夹合并到上一层的include文件夹。
2)修正CMakeLists.txt的错误。
--- httpd-2.4.9.orig\CMakeLists.txt Tue Nov 19 05:18:12 2013 +++ httpd-2.4.9\CMakeLists.txt Mon Apr 21 18:42:32 2014 @@ -678,8 +678,8 @@ IF("${${mod_name}_install_lib}") SET(installed_mod_libs_exps ${installed_mod_libs_exps} - "${PROJECT_BINARY_DIR}/${mod_name}.lib" - "${PROJECT_BINARY_DIR}/${mod_name}.exp" + "${PROJECT_BINARY_DIR}/\${CMAKE_INSTALL_CONFIG_NAME}/${mod_name}.lib" + "${PROJECT_BINARY_DIR}/\${CMAKE_INSTALL_CONFIG_NAME}/${mod_name}.exp" ) ENDIF() SET(mod_extra_libs "${mod_name}_extra_libs") @@ -825,7 +825,7 @@ ) INSTALL(FILES ${other_installed_h} DESTINATION include) INSTALL(FILES ${installed_mod_libs_exps} DESTINATION lib) -INSTALL(FILES "${CMAKE_BINARY_DIR}/libhttpd.exp" DESTINATION LIB) +INSTALL(FILES "${CMAKE_BINARY_DIR}/\${CMAKE_INSTALL_CONFIG_NAME}/libhttpd.exp" DESTINATION LIB) IF(INSTALL_MANUAL) # Silly? This takes a while, and a dev doesn't need it. INSTALL(DIRECTORY docs/manual/ DESTINATION manual) @@ -849,7 +849,7 @@ # Windows anyway. STRING(REPLACE "/" "\\\\" native_src ${CMAKE_BINARY_DIR}/conf/original) STRING(REPLACE "/" "\\\\" native_dest ${CMAKE_INSTALL_PREFIX}/conf/original) -INSTALL(CODE "EXECUTE_PROCESS(COMMAND xcopy ${native_src} ${native_dest} /Q /S /Y)") +INSTALL(CODE "EXECUTE_PROCESS(COMMAND robocopy ${native_src} ${native_dest} /E)") STRING(TOUPPER "${CMAKE_BUILD_TYPE}" buildtype) MESSAGE(STATUS "")
5、使用cmake生成httpd工程(这里使用的是httpd-2.4.9的版本)
这里我们要给定openssl,zlib,pcre,apr,当然如果用得到libxml2也一样给定。
configure,generate,build.
apache2配置SSL客户端认证
配置OpenWRT 校园网实现 IPv4 over IPv6。
目前网络状况:两个位置:位置1和位置2,位置1可以正常访问IPv6网络(校内和校外),位置2可以访问IPv6和IPv4网络。
目的:实现位置1处无差别上网,即正常访问IPv4和IPv6网络,关键是IPv4。
基本原理:通过openvpn路由所有的IPv4数据给远程电脑。
基础设施:位置1处路由器(mdir-615),位置2处做好路由和openvpn()监听IPv4和IPv6地址。
1、基础准备。配置位置2处的电脑,做好openvpn服务器,使用正常的客户端测试openvpn的连通性。网上教程很多,这里不做具体说明了。
2、路由的openwrt配置。这里使用我的DLink dir615 为例说明。
1)刷openwrt,这里需要提到一点,我的dir615刷openwrt,ie11和chrome都不能刷,下了个firefox4可以。
2)安装必备的软件包,由于我的dir615闪存只有4m,所以都不能安装图形界面,还有后面选择polarssl和popenvpn-polarssl,也是次原因,完全命令行操作。必备的软件包有: kmod-tun,liblzo,libpolarssl,openvpn-polarssl。
3)配置
(1)配置/etc/config/system
config system option hostname OpenWrt #路由器的名称 option timezone CST-8 #时区,这个就是Asia/Chongqing,也就是中国的时区。 config 'led' 'wlan_led' #这个是我的dir615配置无线led灯的 option 'name' 'WLAN' option 'sysfs' 'd-link:green:wlan' option 'trigger' 'netdev' option 'dev' 'wlan0' option 'mode' 'link tx rx' config 'led' 'wan_led' #段配置wan口led灯 option 'name' 'WAN' option 'sysfs' 'd-link:green:wan' option 'trigger' 'netdev' option 'dev' 'tun0' option 'mode' 'link tx rx'
(2)配置/etc/config/network
config interface 'wan' option ifname 'eth1' #指定wan口网卡 option proto 'none' #这个地方配置修改为none,我们不需要ipv4网络 option macaddr '00:24:01:76:B2:27' #这句指定wan口的mac地址。 config interface 'ovpn' #这段内容是我们增加的,为后续的防火墙做准备。 option ifname 'tun0' #openvpn使用的interface名称 option proto 'none' #这里也不用配置,他的网络是由程序配置的。
(3)配置/etc/config/firewall
#对wan区域增加我们配置的openvpn,ovpn我们上面刚配置的名字。 config zone option name wan list network 'wan' list network 'wan6' list network 'ovpn' #增加这一行把openvpn增加的wan区域里面,否则即使你连接上了,路由器可以正常上网,但局域网客户端不能上。 option input REJECT option output ACCEPT option forward REJECT option masq 1 option mtu_fix 1
(4)配置dns解析服务,这里我们修改/etc/dnsmasq.conf
#在文件尾部增加DNS服务器,越靠下优先级越高 server=2001:4860:4860::8844 # google ipv6 public dns server=2001:4860:4860::8888 # 同上 server=xxx.xxx.xxx.xxx # 学校IPv4 DNS
(5) 关于openvpn的配置,由于我们没有IPv4网络,redirect gateway回出现错误失效,我们手动添加路由即可。 /etc/config/openvpn
config openvpn sample_client # Set to 1 to enable this instance: option enabled 1 .... #插入以下段到你配置的openvpn client 配置部分 list route "0.0.0.0 0.0.0.0"
(6)顺便把无线的配置也贴出来吧。/etc/config/wireless
config wifi-device radio0 option type mac80211 option channel 11 option hwmode 11ng option path 'platform/ath9k' list ht_capab SHORT-GI-40 list ht_capab DSSS_CCK-40 option htmode HT20 # REMOVE THIS LINE TO ENABLE WIFI: # option disabled 1 #注意这里原来是没有前面那个#的 config wifi-iface option device radio0 option network lan option mode ap #无线工作模式,ap路由,sta客户端 option ssid myssid #OpenWrt #默认是OpenWrt改为你想要的名字 option encryption psk2 #none #默认是none改为你想要的加密方式,psk,psk2,wep等 option key password #当然是密码喽。
Cleanup 一个清理所有节点进程的小Script
#!/bin/bash if [ x$1 = x ]; then echo "use $0 processname to kill all named process on all active nodes." exit fi activenodes=$(shownodes | sed -n 's/\(c[0-9]\{4\}-[0-9]\/8\)/\1/gp' | sed -n 's/ /\n/pg' | sed -n 's/.*\(c[0-9]\{4\}\)-[0-9]\/8.*/\1/gp') #echo $activenodes #run Expect /usr/bin/expect -<<EOD foreach node { $activenodes } { #循环,可以多台相同密码的服务器同时处理,不同密码的需要改动一下,在下面再加一个密码的循环, spawn rsh \$node expect { "*(yes/no)*" { send "yes\r"} "password:" { send "password\r" } } #SSH第一次远程登录服务器 expect "username*" #send "su -\r" #SSH普通用户名密码登录 #expect "Password:" #send "123456\r" #SSH的root用户名密码登录 #expect -timeout 1 #expect "root" send "ps aux | grep $1 \r" send "killall -9 $1 \r" #send "echo helloworld \r" #expect "username" send "exit \r" } EOD echo "Completed"
updated but not tested one
#!/bin/bash if [ x$1 = x ]; then echo "use $0 processname to kill all named process on all active nodes." exit fi activenodes=$(shownodes | sed -n 's/\(c[0-9]\{4\}-[0-9]\/8\)/\1/gp' | sed -n 's/ /\n/pg' | sed -n 's/.*\(c[0-9]\{4\}\)-[0-9]\/8.*/\1/gp') #echo $activenodes logfile="$HOME/bin/cleanup.log" echo "" > $logfile #run Expect /usr/bin/expect -<<EOD foreach node { $activenodes } { #循环,可以多台相同密码的服务器同时处理,不同密码的需要改动一下,在下面再加一个密码的循环, spawn rsh \$node expect { "*(yes/no)*" { send "yes\r"} "password:" { send "password\r" } } #SSH第一次远程登录服务器 expect "usename*" #send "su -\r" #SSH普通用户名密码登录 #expect "Password:" #send "123456\r" #SSH的root用户名密码登录 #expect -timeout 1 #expect "root" send "echo \\\$HOSTNAME >> $logfile \r" send "ps aux | grep $1 | grep -v grep >> $logfile \r" send "killall -9 $1 \r" #send "echo helloworld \r" #expect "sofair" send "exit \r" } EOD echo "Completed" echo "Logs are Saved to $logfile"
Build Mingw64 on MACOSX
主要参照:http://sourceforge.net/apps/trac/mingw-w64/wiki/mingw-w64-howto-build 给出的过程。
这里我们需要注意的几处:
0、依赖
isl,cloog,使用brew安装,这里如果你升级过这些模块或系统,可能会导致模块不兼容,这可以吧这些模块重新安装一下确保兼容。
brew reinstall isl brew link --overwrite isl #reinstall 可能会提示 brew reinstall cloog brew link --overwrite cloog #reinstall 可能会提示
1、安装“mingw64 headers ”
进入“mingw-w64-$version/mingw-w64-headers”目录下的,创建build文件夹,进入build文件夹进行configure,make,make install。
../configure --build=x86_64-pc-mingw32 --host=x86_64-pc-mingw32 --prefix=/opt/mingw64/x86_64-pc-mingw32 make make install
2、进行完整的gcc编译前,把/path/to/mingw64/x86_64-pc-mingw32/lib下面的内容移动到/path/to/mingw64/lib里面,然后创建链接链接到上层lib文件夹,然后在进行编译,否则可能会出现找不到“crtbegin.o crtend.o dllcrt2.o”类似的错误。
cd /path/to/mingw64/lib mv ../x86_64-pc-mingw32/lib/* ./ cd ../x86_64-pc-mingw32 rm -r lib ln -s ../lib ./
Windows Server 2012R2 and Windows8.1 Client Setup Keys
Operating system edition | KMS Client Setup Key |
---|---|
Windows 8.1 Professional |
GCRJD-8NW9H-F2CDX-CCM8D-9D6T9 |
Windows 8.1 Professional N |
HMCNV-VVBFX-7HMBH-CTY9B-B4FXY |
Windows 8.1 Enterprise |
MHF9N-XY6XB-WVXMC-BTDCT-MKKG7 |
Windows 8.1 Enterprise N |
TT4HM-HN7YT-62K67-RGRQJ-JFFXW |
Windows Server 2012 R2 Server Standard |
D2N9P-3P6X9-2R39C-7RTCD-MDVJX |
Windows Server 2012 R2 Datacenter |
W3GGN-FT8W3-Y4M27-J84CP-Q3VJ9 |
Windows Server 2012 R2 Essentials |
KNC87-3J2TX-XB4WP-VCPJV-M4FWM |