2016年12月29日 星期四

ASP.NET MVC ModelState 錯誤訊息

參考:http://www.cnblogs.com/darrenji/p/4415887.html


 if (ModelState.IsValid)
{
        ....
}else{
                String Message = "";
                var errors = ModelState.Where(m => m.Value.Errors.Any())
                    .Select(x => x.Value.Errors);
                foreach (var item in errors)
                {
                    var fieldErrors = item.Select(e => e.ErrorMessage).FirstOrDefault();
                    Message += fieldErrors;
                }
}

2016年12月26日 星期一

PandoraBox pptpd 設定

環境
 LuCI Trunk (0.12+svn-r1024) PandoraBox R2 14.09


安裝
kmod-gre

防火牆設定

防火墙 - 通信规则
打开路由器端口
外部端口:1723

自定义规则
iptables -t nat -I PREROUTING -p gre -j DNAT
iptables -A forwarding_rule -s 192.168.0.0/24 -j ACCEPT
iptables -t nat -A POSTROUTING -s 192.168.0.0/24 -o br-lan -j MASQUERADE

2016年12月2日 星期五

解決 Debian-sh4 for NextVODBox 的 iptables 無法使用

網樂通是安裝下面網址的版本
https://ftp.yzu.edu.tw/Linux/debian-sh4-for-nextvod/download.php

架PPTPD時發現iptables 沒班法用
只好重新編譯Kernel & modules 了..QQ

1.取得config
ssh登入網樂通
取得 /proc/config.gz

2.修改設定
參考這篇
http://mowei-tw.blogspot.tw/2016/12/kernel-modules.html

在編譯的時候
做完make mrproper
config.gz 解壓
把"config" 改名成".config"
mv condig .config

make ARCH=sh CROSS_COMPILE=sh4-linux- menuconfig

參考這文章改設定
https://groups.google.com/forum/#!topic/asterisk-tw/3-Dalh3FZYQ

Networking  ---->
 Networking options  ---->
  Network packet filtering framework (Netfilter)--->
   Core Netfilter Configuration ---->
    <*> Netfilter connection tracking support
    <*> Netfilter Xtables support (required for ip_tables)
    <*>   "NFLOG" target support
    <*>   "conntrack" connection tracking match support
    <*>   "state" match support
   IP: Netfilter Configuration --->
    <*> IPv4 connection tracking support (required for NAT)
    <*> IP tables support (required for filtering/masq/NAT)
    <*>   Packet Filtering
    <*>     REJECT target support
    <*>   Full NAT
    <*>     MASQUERADE target support
    <*> Packet mangling

儲存
蓋過kernel.config
編譯

編譯完檔案:
https://drive.google.com/file/d/0Bx2A-Jefadp8SVFYbGlNZk1HNlU/view?usp=sharing


更換Kernel 
cd /tmp
mkdir boot
mount /dev/sda1 boot
cd boot
把vmlinux.ub 換成新的
mv vmlinux.ub vmlinux.ub.bak
wget (新vmlinux.ub位置)

放置modules 

cd /lib/
mkdir modules 
cd  modules
wget (2.6.32.59-PDK7105-32BITS.tar)
tar -xvf 2.6.32.59-PDK7105-32BITS.tar


都OK後
reboot

uname -a
出現
Linux debian-wheezy-sh4 2.6.32.59-PDK7105-32BITS #6 PREEMPT Fri Dec 2 23:50:40 CST 2016 sh4 GNU/Linux

 iptables -L
不再有錯誤訊息了!
成功

網樂通編譯Kernel & modules

參考網址:
https://xiaolaba.wordpress.com/2012/10/20/ubuntu-12-10-stlinux-2-4/
http://www.twpda.com/2012/10/nextvod-compile-kernel.html
https://github.com/dlintw/kernel-pdk7105/tree/twpda

編譯環境:linuxmint-18-cinnamon-64bit


1.安裝STLinux 2.4



參考
https://xiaolaba.wordpress.com/2012/10/20/ubuntu-12-10-stlinux-2-4/

主要步驟為

下載 ISO 檔
mkdir STLinux
cd STLinux
wget ftp://ftp.stlinux.com/pub/stlinux/2.4/iso/STLinux-2.4-sh4-20121121.iso

掛載 ISO 檔
sudo mkdir /mnt/iso
sudo mount -o loop STLinux-2.4-sh4-20120822.iso /mnt/iso

安裝 STLinux
cd /mnt/iso
sudo ./installb --debian all-sh4-glibc

2.下載原始碼


cd ~/STLinux
wget https://github.com/dlintw/kernel-pdk7105/archive/twpda.zip
unzip twpda.zip


3.編譯


cd kernel-pdk7105-twpda
export PATH=$PATH:/opt/STM/STLinux-2.4/host/bin:/opt/STM/STLinux-2.4/devkit/sh4/bin
make mrproper
sh ./make.sh all



這邊整理一下我編譯出現的問題

1.build-essential 沒安裝
sudo apt-get install build-essential

2.make ARCH=sh CROSS_COMPILE=sh4-linux- menuconfig
出現ncurses問題
sudo apt-get install libncurses5-dev

3.
kernel/timeconst.h error 255
解決辦法:
將kernel/timeconst.pl中第373行的defined()去掉只留下@val就可以了

來源:
https://my.oschina.net/hanxiaodong/blog/755703

4.產生 vmlinux.ub 沒mkimage
sudo apt-get install u-boot-tools

手動產生
mkimage -A sh -O linux -T kernel -C gzip -a 0x80800000 -e 0x80801000  -n "Linux 2.6" -d vmlinux.bin.gz vmlinux.ub

Kernel 編出來的位子
arch/sh/boot/

modules 編出來的位子
lib/modules

預測2031/1/1可能 TWCA 憑證 IOS會出現不信任

緣由: TWCA CYBER Root CA 有兩張、兩個效期 (2030、2047年到期) 推測TWCA 預計 2030年12月會停用: TWCA CYBER Root CA (2030 年到期) TWCA Global Root CA 改用啟用: TWCA CYBER ...