EOS私有网络发行代币

1.进入github上clone下来的eos目录

$ cd ~/eos

2.创建eosio.token

$ cleos create account eosio eosio.token EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV

executed transaction: 29abbafdd8c01c4895db000d2c30338462cf2792b7f5ca55c94544e46167d91e 200 bytes 360 us # eosio <= eosio::newaccount "0000000000ea305500a6823403ea305501000000010002c0ded2bc1f1305fb0faac5e6c03ee3a1924234985427b6167ca56... warning: transaction executed locally, but may not be confirmed by the network yet ]

3.添加eosio.bios合约

eosio.bios合约用于控制资源分配和权限管理

cleos set contract eosio build/contracts/eosio.bios -p eosio@active

4.部署token合约

$ cleos set contract eosio.token build/contracts/eosio.token -p eosio.token

Reading WASM from build/contracts/eosio.token/eosio.token.wasm... Publishing contract... executed transaction: 894586b86e0489e125a425c0cfe5af23e4d1f35748c9df2d74e228dd0a370907 8104 bytes 1907 us # eosio <= eosio::setcode "00a6823403ea305500009594010061736d01000000017e1560037f7e7f0060057f7e7e7f7f0060047f7e7f7f00600000600... # eosio <= eosio::setabi "00a6823403ea3055b4030e656f73696f3a3a6162692f312e30010c6163636f756e745f6e616d65046e616d6505087472616... warning: transaction executed locally, but may not be confirmed by the network yet ] -p,–permission TEXT 表示授权账号,该合约授权给eosio.token账号。
代币合约eosio.token能让许多不同的代币同时在一个智能合约上发行,但是却能被不同用户管理。

5.创建代币

$ cleos push action eosio.token create '[ "eosio.token", "1000000000.0000 SYS"]' -p eosio.token

executed transaction: 50506b4723126945574fdee524c34f4bf349988fbcc4d015a35c0fb0ff9cdb5e 120 bytes 442 us # eosio.token <= eosio.token::create {"issuer":"eosio","maximum_supply":"1000000000.0000 SYS"} warning: transaction executed locally, but may not be confirmed by the network yet ]

create 函数是用来新建一种代币,并输入代币的各种属性,同时 create 函数也是一个 action。action 是 eos 智能合约的接口函数,定义外界可以对智能合约做什么动作。 结合操作命令,说明各个参数的定义: create(
account_name issuer,/发行方账号的名称为”eosio”/
asset maximum_supply,/总供应量为10亿和代币名称/

6.发行代币

$ cleos push action eosio.token issue '[ "111111111111", "10000.0000 SYS", "first SYS issue" ]' -p eosio.token

executed transaction: 87ad76b03fbace95ec435d22d474dffd402d571e51b31bf31f5fd9a2a057aca9 144 bytes 1846 us # eosio.token <= eosio.token::issue {"to":"111111111111","quantity":"10000.0000 SYS","memo":"first ColorBayToken issue"} # eosio.token <= eosio.token::transfer {"from":"eosio","to":"111111111111","quantity":"10000.0000 SYS","memo":"first ColorBayToken issue"} # eosio <= eosio.token::transfer {"from":"eosio","to":"111111111111","quantity":"10000.0000 SYS","memo":"first ColorBayToken issue"} # 111111111111 <= eosio.token::transfer {"from":"eosio","to":"111111111111","quantity":"10000.0000 SYS","memo":"first ColorBayToken issue"}

issue action 来获得代币。
void issue( account_name to, /代币的发行方为账户/
asset quantity, /发行代币的数量为10000个,代币名称为CBT/
string memo ); /表示备注说明,不能超过256个字节/

7.转账

创建账户可参考这里

$ cleos push action eosio.token transfer '[ "111111111111", "111111111112", "8000.0000 SYS", "pay!" ]' -p 111111111111

transfer action 来获得代币。
void transfer(
account_name from, /转账方/
account_name to, /接收方/
asset quantity, /转账的数量/
string memo ); /表示备注说明,不能超过256个字节/

EOS开发环境搭建–账户创建

1.创建钱包

$ cleos wallet create --to-console

Creating wallet: default Save password to use in the future to unlock this wallet. Without password imported keys will not be retrievable. "PW5JvSUVTLst22cjZ1q1mwo6bqgFtEYhNgy1dg6zSDaaYvJp4W2Di"
Creating wallet: default
Save password to use in the future to unlock this wallet.
Without password imported keys will not be retrievable.
“PW5JvSUVTLst22cjZ1q1mwo6bqgFtEYhNgy1dg6zSDaaYvJp4W2Di”

2.创建私钥

$ cleos create key

3.导入私钥

导入上一步生成的私钥

$ cleos wallet import

root@fuck:~/eos# cleos wallet import private key: imported private key for: EOS6dEyb2tydFUrDBg2BZ9s7a8igFkyDNuNh7PWadxK9hp9u9EF6B root@fuck:~/eos# cleos wallet import private key: imported private key for: EOS6iY6sbtVYMhhiJaW228K2iSDxCzR2j88ekJtQeBBwxo828tsTQ
root@fuck:~/eos# cleos wallet import
private key: imported private key for: EOS6dEyb2tydFUrDBg2BZ9s7a8igFkyDNuNh7PWadxK9hp9u9EF6B
root@fuck:~/eos# cleos wallet import
private key: imported private key for: EOS6iY6sbtVYMhhiJaW228K2iSDxCzR2j88ekJtQeBBwxo828tsTQ

4.注册账户名

$ cleos create account eosio 111111111111 EOS6dEyb2tydFUrDBg2BZ9s7a8igFkyDNuNh7PWadxK9hp9u9EF6B EOS6dEyb2tydFUrDBg2BZ9s7a8igFkyDNuNh7PWadxK9hp9u9EF6B

果不其然,报错…..

Error 3090003: Provided keys, permissions, and delays do not satisfy declared authorizations Ensure that you have the related private keys inside your wallet and your wallet is unlocked.
Error 3090003: Provided keys, permissions, and delays do not satisfy declared authorizations
Ensure that you have the related private keys inside your wallet and your wallet is unlocked.

原因是要先导入eosio这个账户,其他的账户再由这个账户生成

eosio public key: EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV
eosio private key: 5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3

导入eosio

$ cleos wallet import --private-key 5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3

executed transaction: 6c6997dda1f91c95f0291fc40338a499ac9b8f4e5b02f2e5bd53db4e6e15ee5c 200 bytes 4601 us # eosio <= eosio::newaccount {"creator":"eosio","name":"111111111111","owner":{"threshold":1,"keys":[{"key":"EOS6dEyb2tydFUrDBg2B... warning: transaction executed locally, but may not be confirmed by the network yet ]
executed transaction: 6c6997dda1f91c95f0291fc40338a499ac9b8f4e5b02f2e5bd53db4e6e15ee5c 200 bytes 4601 us
# eosio <= eosio::newaccount {“creator”:”eosio”,”name”:”111111111111″,”owner”:{“threshold”:1,”keys”:[{“key”:”EOS6dEyb2tydFUrDBg2B…
warning: transaction executed locally, but may not be confirmed by the network yet ]
至此钱包账户生成就完成了

EOS私有网络快速搭建

根据EOS官方推介的操作系统走,用Ubuntu 16.04以上的版本作为运行环境(用其他的很有可能出很多的问题)

1.从全球最大gay交友网站github上下载源码

$ git clone https://github.com/EOSIO/eos --recursive

2.运行eosio_build.sh安装所需的环境和编译环境

$ ./eosio_build.sh

编译成功

根据安装提示,配置mongodb

$ export PATH=${HOME}/opt/mongodb/bin:$PATH

$ /root/opt/mongodb/bin/mongod -f /root/opt/mongodb/mongod.conf &

$ cd /root/eos/build; make test

最后一步有可能会有点儿慢

3.安装

$ ./eosio_install.sh

4.快速启动私有网络

$ nodeos -e -p eosio --plugin eosio::chain_api_plugin --plugin eosio::history_api_plugin

再重新开一个窗口运行

$ cleos get info

至此私有网络搭建成功

进暗网之centOS系统下SOCK5代理搭建教程

之前一直用在用shadowsocks代理,按照网上说的用tor浏览器的时候将代理地址指向本地的ss,估计是姿势不对还是怎么了,一直进不了

SOCK4,各种网桥切换了一遍都上不了,也是醉了,那还不如直接搭一个SOCK5代理吧。

1.先安装依赖包

yum -y install gcc gcc-c++ automake make pam-devel openldap-devel cyrus-sasl-devel openssl-devel

2.下载SS5
https://sourceforge.net/projects/ss5/files/ss5/3.8.9-8/ss5-3.8.9-8.tar.gz

3.解压安装

tar zxvf ./ss5-3.8.9-8.tar.gz
cd ss5-3.8.9
./configure
make
make install

4.随系统一起启动

chmod +x /etc/init.d/ss5
chkconfig --add ss5
chkconfig --level 345 ss5 on

5.修改配置文件

vim /etc/opt/ss5/ss5.conf

将文件中auth和permit修改成如下

6.启动服务

vi service ss5 start

7.至此服务搭建完成

注1.因为默认端口是1080,而且没有密码,所以会被别人盗用,比如被垃圾邮件爬虫爬到,用来发送垃圾邮件(垃圾邮件如果通过同一个IP发送的话容易被封,所有才有了邮件爬虫)

注1-2.修改端口

vim /etc/sysconfig/ss5

添加下面这一行命令,-b后面的参数代表监听的ip地址和端口号
# Add startup option here
SS5_OPTS=” -u root -b 0.0.0.0:8099″

注1-3.重启服务

service ss5 restart

注2.如果还担心的话可以添加一个用户名密码

vim /etc/opt/ss5/ss5.conf

注2-1.将步骤5当中的两行改成

auth 0.0.0.0/0 – u

permit u 0.0.0.0/0 – 0.0.0.0/0 – – – – –

注2-2.添加密码

vim /etc/opt/ss5/ss5.passwd

一行一个账号,用户名和密码之间用空格间隔,例如:

user_1 123456

user_2 123456

注2-3.重启服务

service ss5 restart

至此完美收工

nginx下配置重写模式

废话不多说直接上代码:

server
{
server_name www.yourwebside.com;
index index.html index.htm index.php;
root /your/webside/path/;
fastcgi_connect_timeout 3600;
fastcgi_read_timeout 3600;
fastcgi_send_timeout 3600;
#error_page 404 /404.html;
include enable-php.conf;

location / {
if (!-e $request_filename) {
rewrite ^(.*)$ /index.php?s=$1 last;
break;
}
}

location /nginx_status
{
stub_status on;
access_log off;
}

location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
}

location ~ .*\.(js|css)?$
{
expires 12h;
}

location ~ /\.
{
deny all;
}

access_log /home/wwwlogs/access.log;
}

 

———————分割线———————

其中重写的部分为

location / {
if (!-e $request_filename) {
rewrite ^(.*)$ /index.php?s=$1 last;
break;
}
}

 

AWS中使用S3的时候提示NoSuchBucket解决办法

在阿里云的OSS中使用只要设置好域名CNAME到OSS域名,再在OSS设置好域名就可以了使用了,同样的方法用在AWS的S3上却提示:

404 Not Found

Code: NoSuchBucket
Message: The specified bucket does not exist
BucketName:subject.example.com

如果域名为subject.example.com我们习惯性新建Bucket为subject,在OSS中没有问题,可是在S3中不行,S3中Bucket的命名一定要和域名相同,新建一个Bucket命名为subject.example.com再做下一步的解析即可。

完整的目录结构下载整个网页

目前网络上的大多数的操作方式主要是两种一种是安装插件,二是翻缓存,都挺麻烦的,其实用wget命令有更方便的且保证目录结构完整的方式

wget -r -p -np -k http://www.aaa.com/

-r  –recursive(指定递归下载)
-k   –convert-links(将下载的HTML页面中的链接转换为相对链接即本地链接
-p   –page-requisites(下载所有的图片等页面显示所需的内容)
-np   –no-parent(不追溯至父级)

centos6.x下让redis以服务方式运行

1.从官网下载redis-2.8.9.tar.gz之后,将redis解压在/usr/local下,目录是redis-2.8.9,然后按照官网给出的办法安装redis即可。
2.安装完在redis-2.8.9目录下执行src/redis-server
然后在另一个shell窗口执行src/redis-cli,可以正确运行。
但是我们显然想将之作为服务来启动运行。

3.下面是将redis配置为服务的操作步骤,首先将utils/redis_init_script文件复制到/etc/init.d下

cp /usr/local/redis-2.8.9/utils/redis_init_script /etc/rc.d/init.d/redis
将redis_init_script复制到/etc/rc.d/init.d/,同时易名为redis

然后vi /etc/rc.d/init.d/redis
在文档第二行添加

# chkconfig: 2345 80 90

然后注意

EXEC=/usr/local/redis/bin/redis-server  
CLIEXEC=/usr/local/redis/bin/redis-cli

因为我们的安装目录是/usr/local/redis-2.8.9,所以上面两行改为

EXEC=/usr/local/redis-2.8.9/src/redis-server  
CLIEXEC=/usr/local/redis-2.8.9/src/redis-cli

还要注意redis文件的

$EXEC $CONF

这里,在CONF后面增加&

$EXEC $CONF &

“&”,即是将服务转到后面运行的意思,否则启动服务时,Redis服务将占据在前台,占用了主用户界面,造成其它的命令执行不了。

4.可以看到在/etc/init.d/redis文件中,有这么一行:

CONF="/etc/redis/${REDISPORT}.conf"

于是将redis配置文件拷贝到/etc/redis/下

mkdir /etc/redis   
cp /usr/local/redis-2.8.9/redis.conf /etc/redis/6379.conf  

5.完成上面的操作之后,即可注册服务:

chkconfig --add redis

然后启动redis服务

service redis start

redis就可以服务方式运行

转载自:http://www.2cto.com/os/201406/307712.html