nastika 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 0dbb2787d3dc972b81c006fad71412af8427e34f
4
+ data.tar.gz: ccb519ab0a1437ecd8fe66a74f251066606afb59
5
+ SHA512:
6
+ metadata.gz: 795b3700c55bfaee959b79a45062e2c2687c19e9af01047eaca636e8e3026f8b8b10ff7b9b62ad5bdaaa0fefc35168bc48e0caa030b04abe146d7befea981866
7
+ data.tar.gz: 92fe1b931cbe499ad489f3f130b83dd215c38258a81292dc7addfaf9d80762b8691e81e76d8cd37c278012a481d1379016b7e96aec7342bc6ef20fb5b90de03a
@@ -0,0 +1,12 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+
11
+ # rspec failure tracking
12
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --require spec_helper
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.3.3
5
+ before_install: gem install bundler -v 1.14.6
@@ -0,0 +1,75 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at grwhite31@gmail.com
59
+ . All
60
+ complaints will be reviewed and investigated and will result in a response that
61
+ is deemed necessary and appropriate to the circumstances. The project team is
62
+ obligated to maintain confidentiality with regard to the reporter of an incident.
63
+ Further details of specific enforcement policies may be posted separately.
64
+
65
+ Project maintainers who do not follow or enforce the Code of Conduct in good
66
+ faith may face temporary or permanent repercussions as determined by other
67
+ members of the project's leadership.
68
+
69
+ ## Attribution
70
+
71
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
72
+ available at [http://contributor-covenant.org/version/1/4][version]
73
+
74
+ [homepage]: http://contributor-covenant.org
75
+ [version]: http://contributor-covenant.org/version/1/4/
@@ -0,0 +1,3 @@
1
+ ## Contributing
2
+
3
+ Bug reports and pull requests are welcome on GitHub at https://github.com/Gr3atWh173/nastika. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in nastika.gemspec
4
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 Great White
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,35 @@
1
+ # Nastika
2
+
3
+ Under construction Ruby gem for Server stress testing.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'nastika'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install nastika
20
+
21
+ ## Development
22
+
23
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
24
+
25
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
26
+
27
+ ## Contributing
28
+
29
+ Bug reports and pull requests are welcome on GitHub at https://github.com/Gr3atWh173/nastika. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
30
+
31
+
32
+ ## License
33
+
34
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
35
+
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "nastika"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,2 @@
1
+ require_relative "./nastika/http.rb"
2
+ require_relative "./nastika/version.rb"
@@ -0,0 +1,100 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'socket'
4
+ require 'timeout'
5
+
6
+ require_relative 'constants'
7
+
8
+ module Nastika
9
+
10
+ # It serves as a layer of abstraction between
11
+ # us and Ruby's socket library.
12
+ class Base
13
+ attr_accessor :host
14
+ attr_accessor :port
15
+ attr_accessor :payload
16
+ attr_accessor :protocol
17
+ attr_accessor :sock
18
+ attr_accessor :connected
19
+
20
+ # Initializes the Nastika::Base object
21
+ # Params:
22
+ # +protocol+:: The protocol to use.
23
+ # +host+:: The host to connect to (can be nil)
24
+ # +port+:: The port on the host (can be nil)
25
+ # +payload+:: The payload to send to the host (can be nil)
26
+ def initialize(protocol=nil, host=nil, port=nil, payload=nil)
27
+ if protocol.nil?
28
+ raise ArgumentError, "We need atleast a protocol."
29
+ end
30
+ self.host = host
31
+ self.port = port
32
+ self.payload = payload
33
+ self.protocol = protocol
34
+ self.connected = false
35
+ case protocol
36
+ when Nastika::Constants::TCP
37
+ self.sock = Socket.new(Socket::AF_INET, Socket::SOCK_STREAM, 0)
38
+ when Nastika::Constants::UDP
39
+ self.sock = Socket.new(Socket::AF_INET, Socket::SOCK_DGRAM, 0)
40
+ else
41
+ raise ArgumentError, "#{protocol} is not supported. Try all-lowercase."
42
+ end
43
+ end
44
+
45
+ # Sends data to host. If payload is empty,
46
+ # uses the passed argument and sets it as the payload.
47
+ # Params:
48
+ # +pd+:: the payload to send (can be nil if payload was set beforehand.)
49
+ def send(pd=nil)
50
+ if self.payload.nil?
51
+ self.payload = pd
52
+ to_send = self.payload
53
+ elsif self.payload
54
+ to_send = self.payload
55
+ else
56
+ raise ArgumentError, "cannot send nil payload."
57
+ end
58
+ begin
59
+ self.sock.write(to_send)
60
+ rescue => e
61
+ puts e
62
+ end
63
+ end
64
+
65
+ # Gets data from the host.
66
+ # Params:
67
+ # +bytes+:: the amount of bytes to recieve (can be nil) (Default: 1024)
68
+ # +timeout+:: the amount of time to wait for data (in secs) (can be nil) (Default: 10)
69
+ def get(bytes=Nastika::Constants::DEFAULT_BYTES, timeout=Nastika::Constants::DEFAULT_WAIT_TIME)
70
+ Timeout.timeout(timeout) do
71
+ begin
72
+ recvd = self.sock.recv(bytes)
73
+ rescue => e
74
+ raise e
75
+ end
76
+ end
77
+ end
78
+
79
+ # Connects to the host
80
+ def connect
81
+ unless host.nil? & port.nil?
82
+ begin
83
+ self.sock.connect(Socket.sockaddr_in(port, host))
84
+ self.connected = true
85
+ rescue => e
86
+ self.connected = false
87
+ raise e
88
+ end
89
+ else
90
+ raise ArgumentError, "host and port cannot be nil."
91
+ end
92
+ end
93
+
94
+ # closes the connection
95
+ def quit
96
+ self.sock.close if self.connected
97
+ end
98
+ end
99
+
100
+ end
@@ -0,0 +1,14 @@
1
+ module Nastika
2
+ module Constants
3
+ TCP = "tcp"
4
+ UDP = "udp"
5
+ VERSION = "0.0.1"
6
+ DEFAULT_BYTES = 1024
7
+ DEFAULT_WAIT_TIME = 10
8
+ DEFAULT_PAYLOAD = "GET / HTTP/1.0\r\n\r\n"
9
+ DEFAULT_HEADERS = {"User-Agent" => "Nastika #{VERSION}"}
10
+ DEFAULT_REQTYPE = "GET"
11
+ DEFAULT_REQPATH = "/"
12
+ DEFAULT_HTTPVER = "1.0"
13
+ end
14
+ end
@@ -0,0 +1,49 @@
1
+ require_relative 'tcp.rb'
2
+ require_relative 'http_response.rb'
3
+ require_relative 'http_get_request.rb'
4
+ require_relative 'http_post_request.rb'
5
+ require_relative 'http_head_request.rb'
6
+
7
+ module Nastika
8
+
9
+ # Implements the HTTP functionality
10
+ class HTTP
11
+ attr_accessor :host
12
+ attr_accessor :port
13
+ attr_accessor :response
14
+ attr_accessor :request
15
+
16
+ # Initialized the HTTP object
17
+ # Params:
18
+ # +host+:: Host to connect to
19
+ # +port+:: port to connect to
20
+ # +request+:: request object to send
21
+ def initialize(host=nil, port=nil, request=nil)
22
+ self.host = host
23
+ self.port = port
24
+ self.request = request.to_s
25
+ end
26
+
27
+ # Sends the request and gets the response
28
+ def get_repsonse
29
+ response = Nastika::HTTP::Response.new(make_request)
30
+ end
31
+
32
+ # Makes the request.
33
+ def make_request
34
+ tcp = Nastika::TCP.new(self.host, self.port)
35
+ tcp.payload = self.request
36
+
37
+ begin
38
+ tcp.connect
39
+ tcp.send
40
+ rescue => exception
41
+ raise exception
42
+ ensure
43
+ tcp.close
44
+ end
45
+ end
46
+
47
+ end
48
+
49
+ end
@@ -0,0 +1,37 @@
1
+ module Nastika
2
+
3
+ class HTTP
4
+
5
+ # Crafting get requests
6
+ class Get
7
+ attr_accessor :reqpath
8
+ attr_accessor :headers
9
+ attr_accessor :httpver
10
+
11
+ # Intializes the Get object.
12
+ # Params:
13
+ # +reqpath+:: Path to request
14
+ # +httpver+:: HTTP version to use
15
+ # +headers+:: Additional headers
16
+ def initialize(reqpath=Nastika::Constants::DEFAULT_REQPATH,
17
+ httpver=Nastika::Constants::DEFAULT_HTTPVER,
18
+ headers=Nastika::Constants::DEFAULT_HEADERS)
19
+ self.reqpath = reqpath
20
+ self.headers = headers
21
+ self.httpver = httpver
22
+ end
23
+
24
+ # Convert the object to a string.
25
+ def to_s
26
+ payload = ""
27
+ payload += "GET #{self.reqpath} HTTP/#{self.httpver}\r\n"
28
+ self.headers.each do |key, val|
29
+ payload += "#{key}: #{val}\r\n"
30
+ end
31
+ payload += "\r\n"
32
+ return payload
33
+ end
34
+ end
35
+
36
+ end
37
+ end
@@ -0,0 +1,37 @@
1
+ module Nastika
2
+
3
+ class HTTP
4
+
5
+ # HEAD request
6
+ class Head
7
+ attr_accessor :reqpath
8
+ attr_accessor :headers
9
+ attr_accessor :httpver
10
+
11
+ # Initialize the Nasktika::HTTP object
12
+ # Params:
13
+ # +reqpath+:: Path to include in the request
14
+ # +httpver+:: Http version to use. Default is 1.0
15
+ # +headers+:: Any headers to send with the request.
16
+ def initialize(reqpath=Nastika::Constants::DEFAULT_REQPATH,
17
+ httpver=Nastika::Constants::DEFAULT_HTTPVER,
18
+ headers=Nastika::Constants::DEFAULT_HEADERS)
19
+ self.reqpath = reqpath
20
+ self.headers = headers
21
+ self.httpver = httpver
22
+ end
23
+
24
+ # Converts the request object to a string.
25
+ def to_s
26
+ payload = ""
27
+ payload += "HEAD #{self.reqpath} HTTP/#{self.httpver}\r\n"
28
+ self.headers.each do |key, val|
29
+ payload += "#{key}: #{val}\r\n"
30
+ end
31
+ payload += "\r\n"
32
+ return payload
33
+ end
34
+ end
35
+
36
+ end
37
+ end
@@ -0,0 +1,45 @@
1
+ module Nastika
2
+
3
+ class HTTP
4
+
5
+ # Crafting POST requests
6
+ class Post
7
+ attr_accessor :reqpath
8
+ attr_accessor :headers
9
+ attr_accessor :httpver
10
+ attr_accessor :forminf
11
+
12
+ # Initializes the object
13
+ # Params:
14
+ # +reqpath+:: the path to request
15
+ # +httpver+:: the HTTP version to use
16
+ # +headers+:: Additional headers to use
17
+ # +forminf+:: Form information
18
+ def initialize(reqpath=Nastika::Constants::DEFAULT_REQPATH,
19
+ httpver=Nastika::Constants::DEFAULT_HTTPVER,
20
+ headers=Nastika::Constants::DEFAULT_HEADERS,
21
+ forminf=Nastika::Constants::DEFAULT_FORMINF)
22
+ self.reqpath = reqpath
23
+ self.headers = headers
24
+ self.httpver = httpver
25
+ self.forminf = forminf
26
+ end
27
+
28
+ # Convert the object to a string
29
+ def to_s
30
+ payload = ""
31
+ payload += "POST #{self.reqpath} HTTP/#{self.httpver}\r\n"
32
+ self.headers.each do |key, val|
33
+ payload += "#{key}: #{val}\r\n"
34
+ end
35
+ self.forminf.each_with_index do |(key, val), i|
36
+ payload += "#{key}=#{val}"
37
+ payload += "&" unless i == forminf.length-1
38
+ end
39
+ payload += "\r\n\r\n"
40
+ return payload
41
+ end
42
+ end
43
+
44
+ end
45
+ end
@@ -0,0 +1,44 @@
1
+ module Nastika
2
+ # This response class is responsible for
3
+ # parsing reponses from the server. Right now
4
+ # the implementation is very bad.
5
+ # TODO: Fix implementation ASAP.
6
+ class HTTP
7
+ class Response
8
+ attr_accessor :code
9
+ attr_accessor :body
10
+ attr_accessor :headers
11
+ attr_accessor :httpver
12
+ attr_accessor :status
13
+
14
+ # Takes in a response string and parses it to give
15
+ # response code, body, http version, status and headers.
16
+ def initialize(response)
17
+ # HTTP REQ LOOKS LIKE THIS:
18
+ # HTTP/HTTPVER CODE STATUS
19
+ # HEADERS FOLLOWED BY CRLF
20
+ # CRLF
21
+ # OPTIONAL_BODY
22
+ if response.include? "\r\n"
23
+ response = response.split "\r\n"
24
+ else
25
+ response = response.split "\n"
26
+ end
27
+ self.httpver = response[0].split(" ")[0].split("/")[1]
28
+ self.code = response[0].split(" ")[1]
29
+ self.status = response[0].split(" ")[2]
30
+ self.headers = {}
31
+
32
+ response.each_with_index do |a, i|
33
+ if a == ""
34
+ self.body = response[i+1]
35
+ break
36
+ end
37
+ next unless a.include? ":"
38
+ self.headers[a.split(":")[0].strip] = a.split(":")[1].strip
39
+ end
40
+
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,71 @@
1
+ require_relative 'base.rb'
2
+ require_relative 'constants.rb'
3
+
4
+ module Nastika
5
+
6
+ # This class provides way to talk to the host over TCP.
7
+ class TCP
8
+ attr_accessor :host
9
+ attr_accessor :port
10
+ attr_accessor :payload
11
+ attr_accessor :connected
12
+ attr_accessor :connection
13
+
14
+ # Initializes the Nastika::TCP object.
15
+ # WARNING: Does not connect to host automatically.
16
+ # Params:
17
+ # +host+:: Hostname of the target.
18
+ # +port+:: Port on host to connect to.
19
+ # +payload+:: The payload to send to host.
20
+ def initialize(host=nil, port=nil, payload=Nastika::Constants::DEFAULT_PAYLOAD)
21
+ self.host = host
22
+ self.port = port
23
+ self.payload = payload
24
+ self.connected = false
25
+
26
+ unless self.host.nil? & self.port.nil?
27
+ self.connection = Base.new(Nastika::Constants::TCP)
28
+ self.connection.host = self.host
29
+ self.connection.port = self.port
30
+ self.connection.payload = payload
31
+ end
32
+ end
33
+
34
+ # Connects to the host over TCP
35
+ def connect
36
+ if ! self.connected
37
+ begin
38
+ self.connection.connect
39
+ self.connected = true
40
+ self.connection
41
+ rescue SocketError
42
+ raise ArgumentError, "Cannot connect to #{self.host}:#{self.port}"
43
+ end
44
+ else
45
+ raise RuntimeError, "We're already connected."
46
+ end
47
+ end
48
+
49
+ # Sends the payload to the host and returns the read bytes.
50
+ # If a payload is passed as argument, send that else sends the
51
+ # payload set during initialization.
52
+ # Params:
53
+ # +payload+:: Default is "GET / HTTP/1.0\r\n\r\n" or whatever was initialized.
54
+ # +bytes+:: Amount of byted to read from host after sending request.
55
+ def send(paylaod=self.payload, bytes=Nastika::Constants::DEFAULT_BYTES)
56
+ self.connection.send(payload)
57
+ self.connection.get(Nastika::Constants::DEFAULT_BYTES)
58
+ end
59
+
60
+ # Closes the connection
61
+ def close
62
+ if self.connected
63
+ self.connection.quit
64
+ self.connected = false
65
+ else
66
+ raise RuntimeError, "We're not connected yet."
67
+ end
68
+ end
69
+ end
70
+
71
+ end
@@ -0,0 +1,71 @@
1
+ require_relative 'base.rb'
2
+ require_relative 'constants.rb'
3
+
4
+ module Nastika
5
+
6
+ # This class provides way to talk to the host over UDP.
7
+ class UDP
8
+ attr_accessor :host
9
+ attr_accessor :port
10
+ attr_accessor :payload
11
+ attr_accessor :connected
12
+ attr_accessor :connection
13
+
14
+ # Initializes the Nastika::UDP object.
15
+ # WARNING: Does not connect to host automatically.
16
+ # Params:
17
+ # +host+:: Hostname of the target.
18
+ # +port+:: Port on host to connect to.
19
+ # +payload+:: The payload to send to host.
20
+ def initialize(host=nil, port=nil, payload=Nastika::Constants::DEFAULT_PAYLOAD)
21
+ self.host = host
22
+ self.port = port
23
+ self.payload = payload
24
+ self.connected = false
25
+
26
+ unless self.host.nil? & self.port.nil?
27
+ self.connection = Base.new(Nastika::Constants::UDP)
28
+ self.connection.host = self.host
29
+ self.connection.port = self.port
30
+ self.connection.payload = payload
31
+ end
32
+ end
33
+
34
+ # Connects to the host over UDP
35
+ def connect
36
+ if ! self.connected
37
+ begin
38
+ self.connection.connect
39
+ self.connected = true
40
+ self.connection
41
+ rescue SocketError
42
+ raise ArgumentError, "Cannot connect to #{self.host}:#{self.port}"
43
+ end
44
+ else
45
+ raise RuntimeError, "We're already connected."
46
+ end
47
+ end
48
+
49
+ # Sends the payload to the host and returns the read bytes.
50
+ # If a payload is passed as argument, send that else sends the
51
+ # payload set during initialization.
52
+ # Params:
53
+ # +payload+:: Default is "GET / HTTP/1.0\r\n\r\n" or whatever was initialized.
54
+ # +bytes+:: Amount of byted to read from host after sending request.
55
+ def send(paylaod=self.payload, bytes=Nastika::Constants::DEFAULT_BYTES)
56
+ self.connection.send(payload)
57
+ self.connection.get(Nastika::Constants::DEFAULT_BYTES)
58
+ end
59
+
60
+ # Closes the connection
61
+ def close
62
+ if self.connected
63
+ self.connection.quit
64
+ self.connected = false
65
+ else
66
+ raise RuntimeError, "We're not connected yet."
67
+ end
68
+ end
69
+ end
70
+
71
+ end
@@ -0,0 +1,3 @@
1
+ module Nastika
2
+ VERSION = "0.1.1"
3
+ end
@@ -0,0 +1,29 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'nastika/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "nastika"
8
+ spec.version = Nastika::VERSION
9
+ spec.authors = ["Gr3atWh173"]
10
+ spec.email = ["Gr3atWh173@users.noreply.github.com"]
11
+ spec.homepage = "https://github.com/Gr3atWh173/nastika"
12
+
13
+ spec.summary = %q{RubyGem for stress testing servers.}
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
17
+ f.match(%r{^(test|spec|features)/})
18
+ end
19
+ spec.bindir = "bin"
20
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
21
+ spec.require_paths = ["lib"]
22
+
23
+ spec.add_development_dependency "bundler", "~> 1.14"
24
+ spec.add_development_dependency "rake", "~> 10.0"
25
+ spec.add_development_dependency "rspec", "~> 3.0"
26
+ spec.add_development_dependency "logger_lite", "~> 0.1.2"
27
+
28
+ spec.add_runtime_dependency "logger_lite", "~> 0.1.2"
29
+ end
metadata ADDED
@@ -0,0 +1,139 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: nastika
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Gr3atWh173
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-06-22 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.14'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.14'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: logger_lite
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 0.1.2
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 0.1.2
69
+ - !ruby/object:Gem::Dependency
70
+ name: logger_lite
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 0.1.2
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 0.1.2
83
+ description:
84
+ email:
85
+ - Gr3atWh173@users.noreply.github.com
86
+ executables:
87
+ - console
88
+ - setup
89
+ extensions: []
90
+ extra_rdoc_files: []
91
+ files:
92
+ - ".gitignore"
93
+ - ".rspec"
94
+ - ".travis.yml"
95
+ - CODE_OF_CONDUCT.md
96
+ - CONTRIBUTING.md
97
+ - Gemfile
98
+ - LICENSE.txt
99
+ - README.md
100
+ - Rakefile
101
+ - bin/console
102
+ - bin/setup
103
+ - lib/nastika.rb
104
+ - lib/nastika/base.rb
105
+ - lib/nastika/constants.rb
106
+ - lib/nastika/http.rb
107
+ - lib/nastika/http_get_request.rb
108
+ - lib/nastika/http_head_request.rb
109
+ - lib/nastika/http_post_request.rb
110
+ - lib/nastika/http_response.rb
111
+ - lib/nastika/tcp.rb
112
+ - lib/nastika/udp.rb
113
+ - lib/nastika/version.rb
114
+ - nastika.gemspec
115
+ homepage: https://github.com/Gr3atWh173/nastika
116
+ licenses:
117
+ - MIT
118
+ metadata: {}
119
+ post_install_message:
120
+ rdoc_options: []
121
+ require_paths:
122
+ - lib
123
+ required_ruby_version: !ruby/object:Gem::Requirement
124
+ requirements:
125
+ - - ">="
126
+ - !ruby/object:Gem::Version
127
+ version: '0'
128
+ required_rubygems_version: !ruby/object:Gem::Requirement
129
+ requirements:
130
+ - - ">="
131
+ - !ruby/object:Gem::Version
132
+ version: '0'
133
+ requirements: []
134
+ rubyforge_project:
135
+ rubygems_version: 2.5.2
136
+ signing_key:
137
+ specification_version: 4
138
+ summary: RubyGem for stress testing servers.
139
+ test_files: []