started task 7

This commit is contained in:
2025-12-28 03:18:13 +01:00
parent 01bd4ba693
commit ec4234ee13
66 changed files with 2431 additions and 121 deletions

View File

@@ -24,115 +24,130 @@
java -cp "out:lib/*" client.Client
```
### Server commands:
```java
// list of valid commands
private String[] commands = {
"add",
"subtract",
"multiply",
"divide",
"mod",
"power",
"root",
"exit"
};
### inspecting packets using wireshark.
***
#### Normal functions
***
```
I installed wireshark-cli and run
```bash
sudo tshark -i lo -f "tcp port 8080" -z follow,tcp,ascii,0
```
In Client program the interaction looked like this
```
Enter an integer: 4
Enter an integer: 6
The sum is: 10
```
And the output of wireshark was as follows
### inspecting packets using wireshark.
***
#### Normal functions
***
```xml
POST /RPC2 HTTP/1.1
Content-Type: text/xml
User-Agent: Apache XML RPC 3.0 (Sun HTTP Transport)
Cache-Control: no-cache
Pragma: no-cache
Host: localhost:8080
Accept: */*
Connection: keep-alive
Content-Length: 195
I installed wireshark-cli and run
```bash
sudo tshark -i lo -f "tcp port 8080" -z follow,tcp,ascii,0
```
In Client program the interaction looked like this
```
Enter an integer: 4
Enter an integer: 6
The sum is: 10
```
And the output of wireshark was as follows
<?xml version="1.0" encoding="UTF-8"?>
<methodCall>
<methodName>sample.sum</methodName>
<params>
<param>
<value><i4>4</i4></value>
</param>
<param>
<value><i4>6</i4></value>
</param>
</params>
</methodCall>
```xml
POST /RPC2 HTTP/1.1
Content-Type: text/xml
User-Agent: Apache XML RPC 3.0 (Sun HTTP Transport)
Cache-Control: no-cache
Pragma: no-cache
Host: localhost:8080
Accept: */*
Connection: keep-alive
Content-Length: 195
HTTP/1.1 200 OK
Server: Apache XML-RPC 1.0
Connection: close
Content-Type: text/xml
Content-Length: 129
<?xml version="1.0" encoding="UTF-8"?>
<methodCall>
<methodName>sample.sum</methodName>
<params>
<param>
<value><i4>4</i4></value>
</param>
<param>
<value><i4>6</i4></value>
</param>
</params>
</methodCall>
<?xml version="1.0" encoding="UTF-8"?>
<methodResponse>
HTTP/1.1 200 OK
Server: Apache XML-RPC 1.0
Connection: close
Content-Type: text/xml
Content-Length: 129
<?xml version="1.0" encoding="UTF-8"?>
<methodResponse>
<params>
<param>
<value><i4>10</i4></value>
</param>
</params>
</methodResponse>
```
I believe this is the expected result.
***
#### Intentional error
I changed the messge call string to `sample.add` instead of the correct `sample.sum` and run the program. obviously it threw an exception. the http response from wireguard was as follows
```xml
POST /RPC2 HTTP/1.1
Content-Type: text/xml
User-Agent: Apache XML RPC 3.0 (Sun HTTP Transport)
Cache-Control: no-cache
Pragma: no-cache
Host: localhost:8080
Accept: */*
Connection: keep-alive
Content-Length: 196
<?xml version="1.0" encoding="UTF-8"?>
<methodCall>
<methodName>sample.add</methodName>
<params>
<param>
<value><i4>10</i4></value>
<value><i4>23</i4></value>
</param>
<param>
<value><i4>4</i4></value>
</param>
</params>
</methodResponse>
```
I believe this is the expected result.
</methodCall>
***
#### Intentional error
I changed the messge call string to `sample.add` instead of the correct `sample.sum` and run the program. obviously it threw an exception. the http response from wireguard was as follows
```xml
POST /RPC2 HTTP/1.1
Content-Type: text/xml
User-Agent: Apache XML RPC 3.0 (Sun HTTP Transport)
Cache-Control: no-cache
Pragma: no-cache
Host: localhost:8080
Accept: */*
Connection: keep-alive
Content-Length: 196
HTTP/1.1 200 OK
Server: Apache XML-RPC 1.0
Connection: close
Content-Type: text/xml
Content-Length: 265
<?xml version="1.0" encoding="UTF-8"?>
<methodCall>
<methodName>sample.add</methodName>
<params>
<param>
<value><i4>23</i4></value>
</param>
<param>
<value><i4>4</i4></value>
</param>
</params>
</methodCall>
<?xml version="1.0" encoding="UTF-8"?>
<methodResponse>
<fault>
<value>
<struct>
<member>
<name>faultCode</name>
<value><i4>0</i4></value>
</member>
<member>
<name>faultString</name>
<value>No such handler: sample.add</value>
</member>
</struct>
</value>
</fault>
</methodResponse>
```
Again the expected results. I only tested it in one machine. so time will be done may be another time.
HTTP/1.1 200 OK
Server: Apache XML-RPC 1.0
Connection: close
Content-Type: text/xml
Content-Length: 265
<?xml version="1.0" encoding="UTF-8"?>
<methodResponse>
<fault>
<value>
<struct>
<member>
<name>faultCode</name>
<value><i4>0</i4></value>
</member>
<member>
<name>faultString</name>
<value>No such handler: sample.add</value>
</member>
</struct>
</value>
</fault>
</methodResponse>
```
Again the expected results. I only tested it in one machine. so time will be done may be another time.